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

RFC: tab substitution of LaTeX symbols in REPL #6911

Merged
merged 4 commits into from
May 22, 2014
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ New language features

* Improved reporting of syntax errors ([#6179])

REPL improvements
-----------------

* New native-Julia REPL implementation, eliminating many problems
stemming from the old GNU Readline-based REPL ([#6270]).

* Tab-substitution of LaTeX math symbols (e.g. `\alpha` by `α`) ([#6340]).

Library improvements
--------------------

Expand Down
10 changes: 10 additions & 0 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function complete_methods(input::String)
UTF8String[string(m) for m in methods(fn)]
end

include("latex_symbols.jl")

const non_identifier_chars = [" \t\n\"\\'`\$><=:;|&{}()[],+-*/?%^~"...]
const non_filename_chars = [" \t\n\"\\'`@\$><=;|&{("...]

Expand Down Expand Up @@ -172,6 +174,14 @@ function completions(string, pos)
return UTF8String[], 0:-1, false
end

slashpos = rsearch(string, '\\', pos)
if slashpos > 0
latex = get(latex_symbols, string[slashpos:pos], "")
if !isempty(latex)
return [latex], slashpos:pos, true
end
end

dotpos = rsearch(string, '.', pos)
startpos = nextind(string, rsearch(string, non_identifier_chars, pos))

Expand Down
Loading