gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
230 stars 21 forks source link

better unicode substitution #43

Closed dahtah closed 2 years ago

dahtah commented 3 years ago

More of a tip, not sure if it should be a feature? Maybe to be included in the documentation? Anyway: there's a better way to insert unicode characters, and it's xah-math-input. Basically, you type a (Roman) letter like "a", then shift-spc, and it substitutes the Greek equivalent, here α. Much better than \alpha then Tab, especially when you get to \varepsilon. Here's a function that makes it work in the REPL as well:

  (defun julia-snail--xah-math-substitute ()
    (interactive)
    (save-excursion
      (backward-char 1)
      (let ((newchar (xah-math-input--abbr-to-symbol (thing-at-point 'char t))))
        (forward-char 1)
        (vterm-send-backspace)
        (vterm-send-string newchar)
        )
      )) 

and you can add

(define-key julia-snail-repl-mode-map (kbd "S-SPC") 'julia-snail--xah-math-substitute)

in your julia-snail-mode-hook to make it work.

gcv commented 2 years ago

Added to the wiki (which is now linked to in the README): https://github.com/gcv/julia-snail/wiki/Tips-and-Tricks#alternative-unicode-substitution