Why is there a difference in tab completion for names made available through using vs import in the REPL?

julia> using Base: IdentityUnitRange

julia> Iden[TAB] # nothing happens here

julia> import Base: IdentityUnitRange

julia> Iden[TAB] -> IdentityUnitRange # tab completion works now

Why does tab completion not work if the type is made available through using? Often I choose using instead of import to avoid accidentally extending a function, however the absence of tab-completion makes using this form harder.

9 Likes

Yes. It would be nice to know the rhyme and reason.
And this is curious:

julia> import Base.Id[TAB .. TAB] # nothing happens
julia> import Base: Id[TAB] # nothing happens
julia> using ... # same, nothing
julia> Base.Id[TAB] # Bingo! I get completion, so go ahead and complete,
                                # then position cursor at front and type `import`
julia> import Base.IdentityUnitRange

I just found (or likely rediscovered) that import allows completion but using does not. This has been really annoying when doing using APackage: somesymbol and then not being able to complete. I had resorted to this:

macro rusing(ex)
    sym = ex.args[2].value
    expr = :(const $sym = $ex)
    :($(esc(expr)))
end

and

@rusing Base.IdentityUnitRange

But this seems no better than import and it also does not prevent extending what you import.

1 Like

If we do using Plots, then heat<TAB> will autocomplete to heatmap.

If the symbol is not exported then tab completion does not work after using.

module ModA
export asym
asym = 1
end

module ModB
bsym = 1
end
julia> using ModA: asym  # now completion will work
julia> using ModB: bsym  # tab completion will not work for bsym
julia> import ModB: bsym # Now tab completion *will* work
1 Like