Skip to content

Commit

Permalink
Backport of JuliaLang#8725 Fix so @edit works on windows with the d…
Browse files Browse the repository at this point in the history
…efault editor + line number is printed to the user when it is not passed to the editor.
  • Loading branch information
dhoegh committed Oct 21, 2014
1 parent c02c7b6 commit c8695e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function edit(file::String, line::Integer)
f = find_source_file(file)
f != nothing && (file = f)
end
no_line_msg = "Unknown editor: no line number information passed.\nThe method is defined at line $line."
if beginswith(edname, "emacs")
spawn(`$edpath +$line $file`)
elseif edname == "vim"
Expand All @@ -33,15 +34,18 @@ function edit(file::String, line::Integer)
elseif beginswith(edname, "subl")
spawn(`$(shell_split(edpath)) $file:$line`)
elseif OS_NAME == :Windows && (edname == "start" || edname == "open")
spawn(`start /b $file`)
spawn(`cmd /c start /b $file`)
println(no_line_msg)
elseif OS_NAME == :Darwin && (edname == "start" || edname == "open")
spawn(`open -t $file`)
println(no_line_msg)
elseif edname == "kate"
spawn(`$edpath $file -l $line`)
elseif edname == "nano"
run(`$edpath +$line $file`)
else
run(`$(shell_split(edpath)) $file`)
println(no_line_msg)
end
nothing
end
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function find_source_file(file)
(isabspath(file) || isfile(file)) && return file
file2 = find_in_path(file)
file2 != nothing && return file2
file2 = "$JULIA_HOME/../share/julia/base/$file"
file2 = joinpath(JULIA_HOME, DATAROOTDIR, "julia", "base", file)
isfile(file2) ? file2 : nothing
end

Expand Down

0 comments on commit c8695e2

Please sign in to comment.