Skip to content

Commit

Permalink
edit function prompts for which method when multiple available.
Browse files Browse the repository at this point in the history
  • Loading branch information
twadleigh committed Aug 19, 2016
1 parent ec52837 commit 6b6b3d8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,27 @@ function edit(path::AbstractString, line::Integer=0)
nothing
end

edit(f) = edit(functionloc(f)...)
function edit(f)
ms = methods(f)
nm = length(ms)
if nm <= 1
edit(functionloc(f)...)
else
for (i, m) in enumerate(ms)
@printf("%4u: %s\n", i, m)
end
ix = 0
while ix < 1 || ix > nm
print("Which method? [1-$nm] (<Enter> to cancel) > ")
(ix_str = strip(readline())) == "" && return
try
ix = parse(Int, ix_str)
end
end
edit(functionloc(collect(ms)[ix])...)
end
end

edit(f, t::ANY) = edit(functionloc(f,t)...)
edit(file, line::Integer) = error("could not find source file for function")

Expand Down

0 comments on commit 6b6b3d8

Please sign in to comment.