File: racket-unicode-input-method.el

package info (click to toggle)
racket-mode 20210916git0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,076 kB
  • sloc: lisp: 10,354; makefile: 58
file content (291 lines) | stat: -rw-r--r-- 9,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
;;; racket-unicode-input-method.el -*- lexical-binding: t; -*-

;; Copyright (c) 2015-2020 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 <RET> 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
 ;; (added: common math chars currently unsupported)
 ("times "              ["ร—"])
 ("Uparrow "            ["โ‡‘"])
 ("Downarrow "          ["โ‡“"])
 ("Leftrightarrow "     ["โ‡”"])
 ("rightarrow "         ["โ†’"])
 ("leftarrow "          ["โ†"])
 ("Rightarrow "         ["โ‡’"])
 ("Leftarrow "          ["โ‡"])
 ("nwarrow "            ["โ†–"])
 ("nearrow "            ["โ†—"])
 ("uparrow "            ["โ†‘"])
 ("downarrow "          ["โ†“"])
 ("searrow "            ["โ†˜"])
 ("swarrow "            ["โ†™"])
 ("leftrightarrow "     ["โ†”"])
 ("updownarrow "        ["โ‡•"])
 ("aleph "              ["ื"])
 ("emptyset "           ["โˆ…"])
 ("nabla "              ["โˆ‡"])
 ("surd "               ["โˆš"])
 ("negation "           ["ยฌ"])
 ("infinity "           ["โˆž"])
 ("prod "               ["โˆ"])
 ("coprod"              ["โˆ"])
 ("integrate "          ["โˆซ"])
 ("oint "               ["โˆฎ"])
 ("vee "                ["โˆจ"])
 ("wedge "              ["โˆง"])
 ("follows "            ["โˆ˜"])
 ("in "                 ["โˆˆ"])
 ("ni "                 ["โˆ‹"])
 ("notin "              ["โˆ‰"])
 ("sqsubset "           ["โŠ"])
 ("sqsupset "           ["โА"])
 ("sqsubseteq "         ["โŠ‘"])
 ("sqsupseteq "         ["โŠ’"])
 ("subset "             ["โŠ‚"])
 ("superset "           ["โŠƒ"])
 ("subseteq "           ["โІ"])
 ("supseteq "           ["โЇ"])
 ("approx "             ["โ‰ˆ"])
 ("cong "               ["โ‰Œ"])
 ("neq "                ["โ‰ "])
 ("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