;;; racket-unicode-input-method.el --- Racket Unicode helper functions ;; Copyright (c) 2015-2019 by Greg Hendershott ;; Portions Copyright (c) 2010-2011 by Roel van Dijk ;; Author: Greg Hendershott ;; URL: https://github.com/greghendershott/racket-mode ;; License: ;; This is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. This is distributed in the hope that it will be ;; useful, but without any warranty; without even the implied warranty ;; of merchantability or fitness for a particular purpose. See the GNU ;; General Public License for more details. See ;; http://www.gnu.org/licenses/ for details. ;; Following the example of haskell-unicode-input-method.el (require 'quail) ;;;###autoload (defun racket-unicode-input-method-enable () "Set input method to racket-unicode. The racket-unicode input method lets you easily type various Unicode symbols that might be useful when writing Racket code. To automatically enable the racket-unicode input method in racket-mode and racket-repl-mode buffers, put the following code in your Emacs init file: #+BEGIN_SRC elisp (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) #+END_SRC To temporarily enable this input method for a single buffer you can use \"M-x racket-unicode-input-method-enable\". Use the standard Emacs key C-\\ to toggle the input method. When the racket-unicode input method is active, you can for example type \"All\" and it is immediately replaced with \"βˆ€\". A few other examples: | omega | Ο‰ | | x_1 | x₁ | | x^1 | xΒΉ | | A | 𝔸 | | test-->>E | test-->>βˆƒ (racket/redex) | | vdash | ⊒ | To see a table of all key sequences use \"M-x describe-input-method racket-unicode\". If you want to add your own mappings to the \"racket-unicode\" input method, you may add code like the following example in your Emacs init file: #+BEGIN_SRC elisp ;; Either (require 'racket-mode) here, or, if you use ;; use-package, put the code below in the :config section. (with-temp-buffer (racket-unicode-input-method-enable) (set-input-method \"racket-unicode\") (let ((quail-current-package (assoc \"racket-unicode\" quail-package-alist))) (quail-define-rules ((append . t)) (\"^o\" [\"α΅’\"])))) #+END_SRC If you don’t like the highlighting of partially matching tokens you can turn it off by setting `input-method-highlight-flag' to nil." (interactive) (set-input-method "racket-unicode")) (quail-define-package "racket-unicode" ;name "UTF-8" ;language "Ξ»" ;title (in mode line) t ;guidance "Racket Unicode input method." ;docstring nil ;translation-keys nil ;forget-last-selection nil ;deterministic nil ;kbd-translate nil ;show-layout nil ;create-decode-map nil ;maximum-shortest nil ;overlay-plist nil ;update-translation-function nil ;conversion-keys t) ;simple (quail-define-rules ;; Typed Racket ("All " ["βˆ€"]) ("Union " ["U"]) ("Intersection " ["∩"]) ;; Redex ("test-->>E " ["test-->>βˆƒ"]) ;; Turnstile ("vdash " ["⊒"]) ("gg " ["≫"]) ("rightarrow " ["β†’"]) ("Rightarrow " ["β‡’"]) ("Leftarrow " ["⇐"]) ("succ " ["≻"]) ;; Other type rule symbols ("times " ["Γ—"]) ("Uparrow " ["⇑"]) ("Downarrow " ["⇓"]) ("vee " ["∨"]) ("wedge " ["∧"]) ("sqsubset " ["⊏"]) ("sqsupset " ["⊐"]) ("sqsubseteq " ["βŠ‘"]) ("sqsupseteq " ["βŠ’"]) ("sqcap " ["βŠ“"]) ("sqcup " ["βŠ”"]) ("models " ["⊧"]) ;; Greek letters ("alpha " ["Ξ±"]) ("Alpha " ["Ξ‘"]) ("beta " ["Ξ²"]) ("Beta " ["Ξ’"]) ("gamma " ["Ξ³"]) ("Gamma " ["Ξ“"]) ("delta " ["Ξ΄"]) ("Delta " ["Ξ”"]) ("epsilon " ["Ξ΅"]) ("Epsilon " ["Ξ•"]) ("zeta " ["ΞΆ"]) ("Zeta " ["Ξ–"]) ("eta " ["Ξ·"]) ("Eta " ["Ξ—"]) ("theta " ["ΞΈ"]) ("Theta " ["Θ"]) ("iota " ["ΞΉ"]) ("Iota " ["Ξ™"]) ("kappa " ["ΞΊ"]) ("Kappa " ["Κ"]) ("lambda " ["Ξ»"]) ("Lambda " ["Ξ›"]) ("lamda " ["Ξ»"]) ("Lamda " ["Ξ›"]) ("mu " ["ΞΌ"]) ("Mu " ["Μ"]) ("nu " ["Ξ½"]) ("Nu " ["Ν"]) ("xi " ["ΞΎ"]) ("Xi " ["Ξ"]) ("omicron " ["ΞΏ"]) ("Omicron " ["Ο"]) ("pi " ["Ο€"]) ("Pi " ["Ξ "]) ("rho " ["ρ"]) ("Rho " ["Ξ‘"]) ("sigma " ["Οƒ"]) ("Sigma " ["Ξ£"]) ("tau " ["Ο„"]) ("Tau " ["Ξ€"]) ("upsilon " ["Ο…"]) ("Upsilon " ["Ξ₯"]) ("phi " ["Ο†"]) ("Phi " ["Ξ¦"]) ("chi " ["Ο‡"]) ("Chi " ["Ξ§"]) ("psi " ["ψ"]) ("Psi " ["Ξ¨"]) ("omega " ["Ο‰"]) ("Omega " ["Ξ©"]) ("digamma " ["ϝ"]) ("Digamma " ["Ϝ"]) ("san " ["Ο»"]) ("San " ["ΟΊ"]) ("qoppa " ["Ο™"]) ("Qoppa " ["Ϙ"]) ("sampi " ["Ο‘"]) ("Sampi " ["Ο "]) ("stigma " ["Ο›"]) ("Stigma " ["Ϛ"]) ("heta " ["Ν±"]) ("Heta " ["Ν°"]) ("sho " ["ΟΈ"]) ("Sho " ["Ο·"]) ;; Double-struck letters ("|A|" ["𝔸"]) ("|B|" ["𝔹"]) ("|C|" ["β„‚"]) ("|D|" ["𝔻"]) ("|E|" ["𝔼"]) ("|F|" ["𝔽"]) ("|G|" ["𝔾"]) ("|H|" ["ℍ"]) ("|I|" ["𝕀"]) ("|J|" ["𝕁"]) ("|K|" ["𝕂"]) ("|L|" ["𝕃"]) ("|M|" ["𝕄"]) ("|N|" ["β„•"]) ("|O|" ["𝕆"]) ("|P|" ["β„™"]) ("|Q|" ["β„š"]) ("|R|" ["ℝ"]) ("|S|" ["π•Š"]) ("|T|" ["𝕋"]) ("|U|" ["π•Œ"]) ("|V|" ["𝕍"]) ("|W|" ["π•Ž"]) ("|X|" ["𝕏"]) ("|Y|" ["𝕐"]) ("|Z|" ["β„€"]) ("|gamma|" ["β„½"]) ("|Gamma|" ["β„Ύ"]) ("|pi|" ["β„Ό"]) ("|Pi|" ["β„Ώ"]) ;; Quantifiers ("forall " ["βˆ€"]) ("exists " ["βˆƒ"]) ;; Numeric subscripts ("_0 " ["β‚€"]) ("_1 " ["₁"]) ("_2 " ["β‚‚"]) ("_3 " ["₃"]) ("_4 " ["β‚„"]) ("_5 " ["β‚…"]) ("_6 " ["₆"]) ("_7 " ["₇"]) ("_8 " ["β‚ˆ"]) ("_9 " ["₉"]) ;; Numeric superscripts ("^0 " ["⁰"]) ("^1 " ["ΒΉ"]) ("^2 " ["Β²"]) ("^3 " ["Β³"]) ("^4 " ["⁴"]) ("^5 " ["⁡"]) ("^6 " ["⁢"]) ("^7 " ["⁷"]) ("^8 " ["⁸"]) ("^9 " ["⁹"])) (provide 'racket-unicode-input-method) ;;; racket-unicode-input-method.el ends here