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

tab substitution of math symbols to Unicode in REPL #6340

Closed
stevengj opened this issue Mar 31, 2014 · 23 comments
Closed

tab substitution of math symbols to Unicode in REPL #6340

stevengj opened this issue Mar 31, 2014 · 23 comments
Labels
REPL Julia's REPL (Read Eval Print Loop) unicode Related to unicode characters and encodings

Comments

@stevengj
Copy link
Member

As we discussed with @fperez for future IPython work, it would be nice if tab completion were more flexible, and were really "tab substitution". For example, it would be nice to be able to type alpha<tab> and get α as a possible "completion", and more generally to build in Unicode substitution for many common LaTeX math symbols.

@StefanKarpinski
Copy link
Member

+1111111111111111

@cmundi
Copy link
Contributor

cmundi commented Mar 31, 2014

Best... feature... ever. All editors should work this way -- not just REPLs.

@johnmyleswhite
Copy link
Member

Might be a useful source of inspiration: https://github.com/mvoidex/UnicodeMath

@ivarne
Copy link
Member

ivarne commented Mar 31, 2014

Tab substitution is a much better name for what we want.

@cmundi
Copy link
Contributor

cmundi commented Mar 31, 2014

The extension for Sublime is better than nothing yet feels reminiscent of the <alt>+0+codepoint gynmasitics on some platforms. The nice thing about the proposal made by @stevengj is that there is no cognitive context switch, viz. I don't have to branch to a lookup table in my head.

LaTeX does offer some inspiration here, but in the REPL (at least) I still want to be able to type \alpha and have that taken literally as \alpha without having to remember to further escape it. So another nice thing about @stevengj 's suggestion is that it's invoked with an easily-keyed-nonprinting character (<tab>).

Ideally, the REPL mapping would map localised mnemonics to characters read (at startup) from a user-customizable config. So the name for (aka U+2200) might be all<tab> in English and todo<tab> in Spanish. The table could be locale-dependent and still be user-customizable. This is not a portability issue, because only the codepoint is stored.

@ssfrr
Copy link
Contributor

ssfrr commented Mar 31, 2014

I'd vote to use latex symbol names, rather than invent a new set of names
to cover commonly-used math symbols.

It also may be a good idea for these substitutions to start with the
backslash so the space of substitutions is a little smaller, e.g. a<TAB>
isn't likely to pop up with α as a top choice, but \a<TAB> would. This
would definitely be the best way to input unicode characters I've seen so
far.

-s

@StefanKarpinski
Copy link
Member

Agreed on both points – LaTeX symbol names and leading backslash.

@IainNZ
Copy link
Member

IainNZ commented Apr 1, 2014

I would use the backslash but can see anything else being a bit annoying

@simleb
Copy link

simleb commented Apr 1, 2014

In Mathematica1 you can get α by typing <ESC>a<ESC> or <ESC>alpha<ESC>.
When you type ESC, it prints the character which makes it visually clear that you are in that mode. Then you press ESC again to close.

1. Not trying to start a bikeshed, this is just FYI…

But \alpha<tab> is quite nice. \ works as well as a visual separator, and it totally makes sense to use it with LaTeX names. It's actually brilliant!
+1 for not having to type the full word (so we're now talking about tab-completion-substitution :)

@jiahao
Copy link
Member

jiahao commented Apr 1, 2014

👍

@ssfrr
Copy link
Contributor

ssfrr commented Apr 1, 2014

tab complitution?

@cmundi
Copy link
Contributor

cmundi commented Apr 1, 2014

+1 for LaTeX style
-100 for Mathematica style but not trying to set fire to a bikeshed. :)

Would it make sense to support only the most common symbols and let the
user customize a table loaded at startup if that's not enough?
On Mar 31, 2014 9:24 PM, "Simon Leblanc" [email protected] wrote:

In Mathematica1 you can get α by typing a or alpha.
When you type ESC, it prints the character ⦙ which makes it visually
clear that you are in that mode. Then you press ESC again to close.

  1. Not trying to start a bikeshed, this is just FYI…

But \alpha is quite nice. \ works as well as a visual separator, and
it totally makes sense to use it with LaTeX names. It's actually brilliant!
+1 for not having to type the full word (so we're now talking about
tab-completion-substitution :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/6340#issuecomment-39169718
.

@cdsousa
Copy link
Contributor

cdsousa commented Apr 1, 2014

(A slightly-OT trick I set up in my system to type greek symbols: I configured the keyboard layout to be greek while the right Ctrl key is pressed. So I just have to press Ctrl+b to type β or Ctrl+Shift+v to type Ω, everywhere.)

@StefanKarpinski
Copy link
Member

@cdsousa – that's a nifty trick, what OS?

@cdsousa
Copy link
Contributor

cdsousa commented Apr 1, 2014

Well, in my case I do the trick with KDE (System Settings/Input Devices/Keyboard/Advanced/Switching to another layout), but maybe it can be done in other DE and OS with more or less work...

@mbauman
Copy link
Member

mbauman commented Apr 1, 2014

For a similar trick on OS X, see http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html. I use multi-stroke keybindings so that the sequence (option-g, a) prints α (only in native cocoa text controls, but that's nearly everything these days… except terminals). I had been thinking about how to implement something similar in the new REPL, but I like this proposal for \latex_name tab-completion-and-substitution much more.

@stevengj
Copy link
Member Author

stevengj commented Apr 1, 2014

On OSX, if you add a Greek keyboard option, then Cmd-space switches between English and Greek. So you can type "Cmd-space a Cmd-space" to get α. You can do something similar in Windows, as I understand it.

However, easy access to Greek letters is not enough, because you want to be able to easily type ∂x, ∞, ℓ, and so on. This is why LaTeX tab-substitution would come in handy.

@cmundi
Copy link
Contributor

cmundi commented Apr 1, 2014

Like @stevengj said. As understand the discussion, tabsub (neologism?) with LaTeX style would be 100% compatible with system input tricks -- which are pretty cool but wildly inconsistent across OS and Desktop managers.

@stevengj
Copy link
Member Author

It occurred to me that even for "ordinary" tab completion, we may need to replace some of the preceding string. The reason is that the REPL input is unnormalized, whereas tab-completion will need to NFC-normalize before checking for matches. (@loladiro, I'm guessing REPLCompletions is not doing this yet.) The replacement string will similarly be normalized, and hence might need to replace some of the preceding unnormalized string.

So, we have to implement tab substitution, not just tab completion, even without nifty symbol substitution.

@StefanKarpinski
Copy link
Member

Yup. That's a really good point. Even though they're planning on supporting this kind of thing, we should probably point this out to @fperez, et al. for the IPython protocol redesign.

@stevengj
Copy link
Member Author

This is now implemented, and happily it turned out that both the REPL code and IPython already supported tab substitution (not just tab completion).

Now, if only someone would implement this in julia-mode for Emacs...

@cmundi
Copy link
Contributor

cmundi commented May 22, 2014

Very cool!
On May 22, 2014 8:29 AM, "Steven G. Johnson" [email protected]
wrote:

This is now implemented, and happily it turned out that both the REPL code
and IPython already supported tab substitution (not just tab completion).

Now, if only someone would implement this in julia-mode for Emacs...


Reply to this email directly or view it on GitHubhttps://github.com//issues/6340#issuecomment-43881352
.

@jiahao jiahao added the unicode label May 22, 2014
@StefanKarpinski
Copy link
Member

I love that there is a base/latex_symbols.jl file now. Math-oriented programming language, indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop) unicode Related to unicode characters and encodings
Projects
None yet
Development

No branches or pull requests