Skip to content

Commit

Permalink
some updates to edit(), including nano support. ref JuliaLang#4728
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 8, 2013
1 parent 24822f6 commit 8b33ba9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ function edit(file::String, line::Integer)
else
default_editor = "emacs"
end
envvar = haskey(ENV,"JULIA_EDITOR") ? "JULIA_EDITOR" : "EDITOR"
editor = get(ENV, envvar, default_editor)
editor = get(ENV,"JULIA_EDITOR", get(ENV,"VISUAL", get(ENV,"EDITOR", default_editor)))
issrc = length(file)>2 && file[end-2:end] == ".jl"
if issrc
file = find_source_file(file)
end
if editor == "emacs"
if issrc
jmode = "$JULIA_HOME/../../contrib/julia-mode.el"
jmode = joinpath(JULIA_HOME, "..", "..", "contrib", "julia-mode.el")
if issrc && isreadable(jmode)
run(`emacs $file --eval "(progn
(require 'julia-mode \"$jmode\")
(julia-mode)
Expand All @@ -179,6 +178,8 @@ function edit(file::String, line::Integer)
spawn(`open -t $file`)
elseif editor == "kate"
spawn(`kate $file -l $line`)
elseif editor == "nano"
spawn(`nano +$line $file`)
else
run(`$(shell_split(editor)) $file`)
end
Expand Down

0 comments on commit 8b33ba9

Please sign in to comment.