It will be prefect if the Tab can also auto-complete the argument names of a function, like what R did.
Actually I have other complaints about REPL: 1. Ctrl+w delected all the line rather than only the last word. It really make me crazy.... 2. If I push F1 in the REPL in termnal window (it is running in the server), the whole system clashed: julia> ERROR: key not found: '\0' in match_input at LineEdit.jl:734 (repeats 3 times) in match_input at LineEdit.jl:731 in anonymous at LineEdit.jl:833 in prompt! at ./LineEdit.jl:1349 in run_interface at ./LineEdit.jl:1324 in run_interface_3B_9747 at /home/JXiong/programs/julia_0.3/julia/usr/bin/../lib/julia/sys.so in run_frontend at ./REPL.jl:819 in run_repl at ./REPL.jl:170 in _start at ./client.jl:399 in _start_3B_9614 at /home/JXiong/programs/julia_0.3/julia/usr/bin/../lib/julia/sys.so I really like that in MATLAB, I can see the help of the function I am typing just by push F1. I think REPL could also support some hot-keys, like showing help, showing current directory, showing data tip, showing function argument hint, showing command history, and run a custom function during typing the command. In many time, I cannot remember the function argument order when I type command, I have to delete the whole line, check help, and retype it again. How do you think about it? On Wednesday, October 29, 2014 11:02:54 PM UTC+1, Max Suster wrote: > > +1 > > On Wednesday, October 29, 2014 9:56:33 PM UTC+1, Elliot Saba wrote: >> >> I really like the concept; I can't tell you how many times I've tried to >> tab-complete dict keys. >> -E >> >> On Wed, Oct 29, 2014 at 1:36 PM, Ivar Nesje <[email protected]> wrote: >> >>> Nice. What do people think about adding this functionality to Base? >>> >>> If anyone likes to read code in a gist, rather than in an email, I made >>> a link <https://gist.github.com/ivarne/d232c1a815222fc5f896> >>> >>> Regards Ivar >>> >>> kl. 21:07:45 UTC+1 onsdag 29. oktober 2014 skrev [email protected] >>> følgende: >>> >>>> I get it work ^ ^ Haha!! >>>> Thank you for your information! >>>> >>>> First, insert below code in the beginning of "completions" function in >>>> /base/REPLCompletions.jl >>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FJuliaLang%2Fjulia%2Fblob%2Fmaster%2Fbase%2FREPLCompletions.jl%23L185&sa=D&sntz=1&usg=AFQjCNHzQ0VkvZjQihp3roolMlmxAe9LHQ> >>>> : >>>> try >>>> if isdefined(Main, :CUSTOM_AUTOCOMPLETION_HOOK) >>>> t=Main.CUSTOM_AUTOCOMPLETION_HOOK(string, pos) >>>> if t[3] >>>> return t >>>> end >>>> end >>>> catch err >>>> println("Error in CUSTOM_AUTOCOMPLETION_HOOK:") >>>> println(err) >>>> end >>>> And recompile Julia. Now I have a hook for the custom-autocompletion. >>>> >>>> Second, I define such function: >>>> function CUSTOM_AUTOCOMPLETION_HOOK(txt,pos) >>>> m=match(r"(\w+)\[\"([^\"]*)$",txt[1:pos]) >>>> if !isa(m,Nothing) >>>> #For String key >>>> if !isdefined(Main,parse(m.captures[1])) >>>> return UTF8String[], 0:-1, false >>>> end >>>> var=eval(parse(m.captures[1])) >>>> if !applicable(keys,var) >>>> return UTF8String[], 0:-1, false >>>> end >>>> ky=keys(var) >>>> if length(ky)>500 >>>> return UTF8String[], 0:-1, false >>>> end >>>> ky=[filter(x->isa(x,String),ky)...] >>>> lst=convert(Vector{UTF8String},[filter(x->beginswith(x,m. >>>> captures[2]),ky)...]) >>>> if !(length(txt)>=pos+1 && txt[pos+1]=='\"') >>>> if length(txt)>=pos+1 && txt[pos+1]==']' >>>> lst=map(x->x*"\"",lst) >>>> else >>>> lst=map(x->x*"\"]",lst) >>>> end >>>> end >>>> return lst, (pos-length(m.captures[2])+1):pos, true >>>> else >>>> #For symbol key >>>> m=match(r"(\w+)\[\:(\w*)$",txt[1:pos]) >>>> if isa(m,Nothing) || !isdefined(Main,parse(m.captures[1])) >>>> return UTF8String[], 0:-1, false >>>> end >>>> var=eval(parse(m.captures[1])) >>>> if !applicable(keys,var) >>>> return UTF8String[], 0:-1, false >>>> end >>>> ky=keys(var) >>>> if length(ky)>500 >>>> return UTF8String[], 0:-1, false >>>> end >>>> ky=map(string,[filter(x->isa(x,Symbol),ky)...]) >>>> lst=convert(Vector{UTF8String},[filter(x->beginswith(x,m. >>>> captures[2]),ky)...]) >>>> if !(length(txt)>=pos+1 && txt[pos+1]==']') >>>> lst=map(x->x*"]",lst) >>>> end >>>> return lst, (pos-length(m.captures[2])+1):pos, true >>>> end >>>> end >>>> >>>> Now it is work on string and symbol key, really cool! >>>> It can also auto-complete the method of python object ^ ^v >>>> >>>> On Wednesday, October 29, 2014 11:47:32 AM UTC+1, Ivar Nesje wrote: >>>>> >>>>> That would be cool! >>>>> >>>>> Currently there isn't any hooks you can use for that purpose (I >>>>> believe), but as most of Julia is written in Julia, it should be a >>>>> reasonable project to include the required functionality in >>>>> /base/REPLCompletions.jl >>>>> <https://github.com/JuliaLang/julia/blob/master/base/REPLCompletions.jl#L185> >>>>> and submit a pull request on Github. This would likely be nice for >>>>> other associative structures (PyCall anyone?) also. >>>>> >>>>> You will have to look for unclosed `[` that is either empty or >>>>> continue with a `:` indicating a symbol or `"` indicating a string index. >>>>> >>>>> Ivar >>>>> >>>>> kl. 10:06:19 UTC+1 onsdag 29. oktober 2014 skrev [email protected] >>>>> følgende: >>>>>> >>>>>> Is there any way to add an customal autocomplete list to Julia REPL? >>>>>> For example, I really hope the Dict can be as convenient as MATLAB >>>>>> structure that the keys can be autpcompleted in command line. >>>>>> >>>>> >>
