Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more docs to repl completion. #17580

Merged
merged 2 commits into from
Jul 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion doc/manual/interacting-with-julia.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,56 @@ and get a list of LaTeX matches as well::
\hat \heartsuit \hksearow \hookleftarrow \hslash
\hbar \hermitconjmatrix \hkswarow \hookrightarrow \hspace

julia> α="\alpha[TAB]" # LaTeX completion also works in strings
julia> α="α"

A full list of tab-completions can be found in the :ref:`man-unicode-input` section of the manual.

Completion of paths works for strings and julia's shell mode::

julia> path="/[TAB]"
.dockerenv .juliabox/ boot/ etc/ lib/ media/ opt/ root/ sbin/ sys/ usr/
.dockerinit bin/ dev/ home/ lib64/ mnt/ proc/ run/ srv/ tmp/ var/
shell> /[TAB]
.dockerenv .juliabox/ boot/ etc/ lib/ media/ opt/ root/ sbin/ sys/ usr/
.dockerinit bin/ dev/ home/ lib64/ mnt/ proc/ run/ srv/ tmp/ var/

Tab completion can help with investigation of the available methods matching the input arguments::

julia> max([TAB] # All methods are displayed, not shown here due to size of the list

julia> max([1,2],[TAB] # All methods where `Vector{Int}` matches as first argument
max{T1<:Real,T2<:Real}(x::AbstractArray{T1,N<:Any}, y::T2) at operators.jl:544
max{Tx<:Real,Ty<:Real}(x::Union{Base.ReshapedArray{Tx,1,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N<:Any}}},DenseArray{Tx,1},SubArray{Tx,1,A<:Union{Base.ReshapedArray{T<:Any,N<:Any,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N<:Any}}},DenseArray},I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex,Colon,Int64,Range{Int64}},N<:Any}},L<:Any}}, y::AbstractSparseArray{Ty,Ti<:Any,1}) at sparse\sparsevector.jl:1127
max{T1<:Real,T2<:Real}(x::AbstractArray{T1,N<:Any}, y::AbstractArray{T2,N<:Any}) at operators.jl:548
max(x, y) at operators.jl:78
max(a, b, c, xs...) at operators.jl:119

julia> max([1,2], max(1,2),[TAB] # All methods matching the arguments.
max{T1<:Real,T2<:Real}(x::AbstractArray{T1,N<:Any}, y::T2) at operators.jl:544
max(x, y) at operators.jl:78
max(a, b, c, xs...) at operators.jl:119

julia> split("1 1 1", # Keywords are also displayed in the suggested methods, see second line after `;` where `limit` and `keep` are keyword arguments
split(str::AbstractString) at strings/util.jl:151
split{T<:AbstractString}(str::T, splitter; limit, keep) at strings/util.jl:127

The completion of the methods uses type inference and can therefore see if the arguments match even if the arguments are output from functions. The function needs to be type stable for the completion to be able to remove non-matching methods.

Tab completion can also help completing fields::

julia> Pkg.a
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we typically call a function in a module for a field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know, but Pkg,.add operation is lowered to getfield(Pkg,:add)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question whether there's a better name for module children than "field," maybe not.

add available

Fields for output from functions can also be completed::

julia> split("","")[1].[TAB]
endof offset string

The completion of fields for output from functions uses type inference, and it can only suggest fields if the function is type stable.

Customizing Colors
~~~~~~~~~~~~~~~~~~
------------------

The colors used by Julia and the REPL can be customized, as well. To change the color of the Julia
prompt you can add something like the following to your ``juliarc.jl`` file::
Expand Down