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

REPL help for LaTeX tab completion #19858

Merged
merged 5 commits into from
Jan 6, 2017
Merged

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 4, 2017

In this PR, typing a Unicode symbol into the REPL help now prints information about how to type it using the LaTeX tab completion, if possible:

help?> √
"√" can be typed by \sqrt<tab>

search: √

  sqrt(x)

  Return \sqrt{x}. Throws DomainError for negative Real arguments. Use complex
  negative arguments instead. The prefix operator √ is equivalent to sqrt.

help?> x̂₂
"x̂₂" can be typed by x\hat<tab>\_2<tab>

search:

Couldn't find x̂₂
Perhaps you meant xor, exit, exp, exp2, expm, Expr, hex, max, !, !=, !==, $, % or &
  No documentation found.

  Binding x̂₂ does not exist.

While I was editing this code, I also made it possible to get the help text in a user-supplied io stream rather than STDOUT, which will help with IJulia and similar enviroments.

@stevengj stevengj added the docsystem The documentation building system label Jan 4, 2017
Copy link
Member

@MichaelHatherly MichaelHatherly left a comment

Choose a reason for hiding this comment

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

LGTM, I assume that the usefulness of this feature is more for longer tab-completed names such as

help?> x_φ̄⁵
"x_φ̄⁵" can be typed by x_\varphi<tab>\bar<tab>\^5<tab>

that could be tab completed with x_<tab> rather than single symbols such as

help?> φ
"φ" can be typed by \varphi<tab>

where the user would have had to input the symbol with \varphi<tab> to begin with anyway (usually, though perhaps they copy-pasted it from some where).

end
repl_latex(s::String) = repl_latex(STDOUT, s)

macro repl(ex...) length(ex) == 2 ? repl(ex[1], ex[2]) : repl(ex[1]) end
Copy link
Member

Choose a reason for hiding this comment

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

Could use two definitions for dispatch to avoid needing the conditional: macro repl(ex) ... and macro repl(io, ex) ..., not too important though really.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I didn't realize that dispatch could be used for macros. Learn something new every day.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

@MichaelHatherly, I think it is useful for single symbols, too. There are other (more annoying) ways to type these symbols than by tab completion.

For example, you could be looking at someone else's code, see a symbol you don't know how to type, and find out by copy-and-pasting it into the REPL help.

Or you could type the symbol on MacOS by the character palette, or by copying and pasting from a web page, or ...

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

(For example, if you look at ?sqrt, the help text tells you about but not how to type it, so you could copy-and-paste that into ?√.)

@stevengj
Copy link
Member Author

stevengj commented Jan 5, 2017

Should be good to merge; the Travis failure is the unrelated x86 problem we are having nowadays.

@stevengj stevengj merged commit 84d9eac into JuliaLang:master Jan 6, 2017
@stevengj stevengj deleted the helptab branch January 6, 2017 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docsystem The documentation building system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants