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://github.com/JuliaLang/julia/blob/master/base/REPLCompletions.jl#L185> : 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 xiong...@gmail.com > 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. >> >