1 ;;; latin-ltx.el --- Quail package for TeX-style input -*-coding: utf-8;-*-
3 ;; Copyright (C) 2001-2013 Free Software Foundation, Inc.
4 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H14PRO021
9 ;; Author: TAKAHASHI Naoto <ntakahas@m17n.org>
10 ;; Dave Love <fx@gnu.org>
11 ;; Keywords: multilingual, input, Greek, i18n
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation, either version 3 of the License, or
18 ;; (at your option) any later version.
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
36 "LaTeX-like input method for many characters.
37 These characters are from the charsets used by the `utf-8' coding
38 system, including many technical ones. Examples:
40 \\pi -> π \\int -> ∫ ^1 -> ¹"
42 '(("\t" . quail-completion))
43 t t nil nil nil nil nil nil nil t)
46 (defun latin-ltx--ascii-p (char)
47 (and (characterp char) (< char 128)))
49 (defmacro latin-ltx--define-rules (&rest rules)
54 (`(,_ ,(pred characterp)) (push rule newrules)) ;; Normal quail rule.
57 (dolist (pair (ucs-names))
58 (let ((name (car pair))
60 (when (and (characterp char) ;; Ignore char-ranges.
61 (string-match re name))
62 (let ((keys (if (stringp seq)
63 (replace-match seq nil nil name)
64 (funcall seq name char))))
67 (setq count (1+ count))
68 (push (list x char) newrules))
69 (setq count (1+ count))
70 (push (list keys char) newrules))))))
71 ;(message "latin-ltx: %d mapping for %S" count re)
73 `(quail-define-rules ,@(nreverse (delete-dups newrules))))))
75 (latin-ltx--define-rules
77 ("\\pounds" ?£) ;; ("{\\pounds}" ?£)
78 ("\\S" ?§) ;; ("{\\S}" ?§)
80 ("$\\pm$" ?±) ("\\pm" ?±)
83 ("\\P" ?¶) ;; ("{\\P}" ?¶)
84 ;; Fixme: Yudit has the equivalent of ("\\cdot" ?⋅), for U+22C5, DOT
85 ;; OPERATOR, whereas · is MIDDLE DOT. JadeTeX translates both to
87 ("$\\cdot$" ?·) ("\\cdot" ?·)
95 (let ((c (if (match-end 1)
96 (downcase (match-string 2 name))
97 (match-string 2 name))))
98 (list (format "\\`{%s}" c) (format "\\`%s" c))))
99 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH GRAVE")
104 (let ((c (if (match-end 1)
105 (downcase (match-string 2 name))
106 (match-string 2 name))))
107 (list (format "\\'{%s}" c) (format "\\'%s" c))))
108 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH ACUTE")
113 (let ((c (if (match-end 1)
114 (downcase (match-string 2 name))
115 (match-string 2 name))))
116 (list (format "\\^{%s}" c) (format "\\^%s" c))))
117 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH CIRCUMFLEX")
122 (let ((c (if (match-end 1)
123 (downcase (match-string 2 name))
124 (match-string 2 name))))
125 (list (format "\\~{%s}" c) (format "\\~%s" c))))
126 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH TILDE")
131 (let ((c (if (match-end 1)
132 (downcase (match-string 2 name))
133 (match-string 2 name))))
134 (list (format "\\\"{%s}" c) (format "\\\"%s" c))))
135 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH DIAERESIS")
140 (let ((c (if (match-end 1)
141 (downcase (match-string 2 name))
142 (match-string 2 name))))
143 (list (format "\\k{%s}" c) ;; (format "\\k%s" c)
145 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH OGONEK")
150 (let ((c (if (match-end 1)
151 (downcase (match-string 2 name))
152 (match-string 2 name))))
153 (list (format "\\c{%s}" c) (format "\\c%s" c))))
154 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH CEDILLA")
156 ("\\AA" ?Å) ;; ("{\\AA}" ?Å)
157 ("\\AE" ?Æ) ;; ("{\\AE}" ?Æ)
159 ("$\\times$" ?×) ("\\times" ?×)
160 ("\\O" ?Ø) ;; ("{\\O}" ?Ø)
161 ("\\ss" ?ß) ;; ("{\\ss}" ?ß)
163 ("\\aa" ?å) ;; ("{\\aa}" ?å)
164 ("\\ae" ?æ) ;; ("{\\ae}" ?æ)
166 ("$\\div$" ?÷) ("\\div" ?÷)
167 ("\\o" ?ø) ;; ("{\\o}" ?ø)
172 (let ((c (if (match-end 1)
173 (downcase (match-string 2 name))
174 (match-string 2 name))))
175 (list (format "\\={%s}" c) (format "\\=%s" c))))
176 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH MACRON")
181 (let ((c (if (match-end 1)
182 (downcase (match-string 2 name))
183 (match-string 2 name))))
184 (list (format "\\u{%s}" c) (format "\\u%s" c))))
185 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH BREVE")
190 (let ((c (if (match-end 1)
191 (downcase (match-string 2 name))
192 (match-string 2 name))))
193 (list (format "\\.{%s}" c) (format "\\.%s" c))))
194 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH DOT ABOVE")
199 (let ((c (if (match-end 1)
200 (downcase (match-string 2 name))
201 (match-string 2 name))))
202 (list (format "\\v{%s}" c) (format "\\v%s" c))))
203 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH CARON")
209 ("\\i" ?ı) ;; ("{\\i}" ?ı)
212 ("\\L" ?Ł) ;; ("{\\L}" ?Ł)
213 ("\\l" ?ł) ;; ("{\\l}" ?ł)
218 (let ((c (if (match-end 1)
219 (downcase (match-string 2 name))
220 (match-string 2 name))))
221 (list (format "\\H{%s}" c) (format "\\H%s" c))))
222 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH DOUBLE ACUTE")
223 ("\\U{o}" ?ő) ("\\Uo" ?ő) ;; FIXME: Was it just a typo?
225 ("\\OE" ?Œ) ;; ("{\\OE}" ?Œ)
226 ("\\oe" ?œ) ;; ("{\\oe}" ?œ)
230 ("\\={\\AE}" ?Ǣ) ("\\=\\AE" ?Ǣ)
231 ("\\={\\ae}" ?ǣ) ("\\=\\ae" ?ǣ)
234 ("\\'{\\AE}" ?Ǽ) ("\\'\\AE" ?Ǽ)
235 ("\\'{\\ae}" ?ǽ) ("\\'\\ae" ?ǽ)
236 ("\\'{\\O}" ?Ǿ) ("\\'\\O" ?Ǿ)
237 ("\\'{\\o}" ?ǿ) ("\\'\\o" ?ǿ)
245 (let* ((base (concat (match-string 1 name) (match-string 3 name)))
246 (basechar (cdr (assoc base (ucs-names)))))
247 (when (latin-ltx--ascii-p basechar)
248 (string (if (match-end 2) ?^ ?_) basechar))))
249 "\\(.*\\)SU\\(?:B\\|\\(PER\\)\\)SCRIPT \\(.*\\)")
252 (let* ((basename (match-string 2 name))
253 (lbase (format "LATIN %s LETTER %s"
254 (match-string 1 name) basename))
255 (gbase (format "GREEK %s LETTER %s"
256 (match-string 1 name) basename))
259 ((assoc gbase (ucs-names)) (concat "^\\" (downcase basename)))
260 ((latin-ltx--ascii-p (setq tmp (cdr (assoc lbase (ucs-names)))))
262 (t (message "Unknown modifier letter %s" basename)))))
263 "MODIFIER LETTER \\(SMALL\\|CAPITAL\\) \\(.*\\)")
265 ;; ((lambda (name char) (format "^%s" (downcase (match-string 1 name))))
266 ;; "\\`MODIFIER LETTER SMALL \\(.\\)\\'")
267 ;; ("^\\1" "\\`MODIFIER LETTER CAPITAL \\(.\\)\\'")
276 ;; ("\\d{}" ?) ;; FIXME: can't find the DOT BELOW character.
278 (let ((c (if (match-end 1)
279 (downcase (match-string 2 name))
280 (match-string 2 name))))
281 (list (format "\\d{%s}" c) ;; (format "\\d%s" c)
283 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH DOT BELOW")
287 ;; FIXME: Provides some useful entries (yen, euro, copyright, registered,
288 ;; currency, minus, micro), but also a lot of dubious ones.
290 (unless (latin-ltx--ascii-p char)
291 (concat "\\" (downcase (match-string 1 name)))))
292 "\\`\\([^- ]+\\) SIGN\\'")
295 (concat "\\" (funcall (if (match-end 1) #' capitalize #'downcase)
296 (match-string 2 name))))
297 "\\`GREEK \\(?:SMALL\\|CAPITA\\(L\\)\\) LETTER \\([^- ]+\\)\\'")
309 ("\\Leftrightarrow" ?⇔)
312 ("\\Longleftarrow" ?⇐)
313 ("\\Longleftrightarrow" ?⇔)
314 ("\\Longrightarrow" ?⇒)
348 ("\\bigtriangledown" ?▽)
349 ("\\bigtriangleup" ?△)
352 ("\\blacklozenge" ?✦)
354 ("\\blacktriangle" ?▴)
355 ("\\blacktriangledown" ?▾)
356 ("\\blacktriangleleft" ?◂)
357 ("\\blacktriangleright" ?▸)
372 ("\\circlearrowleft" ?↺)
373 ("\\circlearrowright" ?↻)
380 ("\\colon" ?:) ;FIXME: Conflict with "COLON SIGN" ₡.
391 ("\\curvearrowleft" ?↶)
392 ("\\curvearrowright" ?↷)
404 ("\\divideontimes" ?⋇)
410 ("\\downdownarrows" ?⇊)
411 ("\\downleftharpoon" ?⇃)
412 ("\\downrightharpoon" ?⇂)
421 ("\\fallingdotseq" ?≒)
462 ("\\hookleftarrow" ?↩)
463 ("\\hookrightarrow" ?↪)
470 ("\\langle" ?⟨) ;; Was ?〈, see bug#12948.
478 ("\\leftarrowtail" ?↢)
479 ("\\leftharpoondown" ?↽)
480 ("\\leftharpoonup" ?↼)
481 ("\\leftleftarrows" ?⇇)
482 ;; ("\\leftparengtr" ?〈), see bug#12948.
483 ("\\leftrightarrow" ?↔)
484 ("\\leftrightarrows" ?⇆)
485 ("\\leftrightharpoons" ?⇋)
486 ("\\leftrightsquigarrow" ?↭)
487 ("\\leftthreetimes" ?⋋)
506 ("\\longleftarrow" ?←)
507 ("\\longleftrightarrow" ?↔)
509 ("\\longrightarrow" ?→)
510 ("\\looparrowleft" ?↫)
511 ("\\looparrowright" ?↬)
519 ("\\measuredangle" ?∡)
526 ("\\nLeftrightarrow" ?⇎)
547 ("\\nleftrightarrow" ?↮)
553 ("\\not" ?̸) ;FIXME: conflict with "NOT SIGN" ¬.
560 ("\\nshortparallel" ?∦)
571 ("\\ntriangleleft" ?⋪)
572 ("\\ntrianglelefteq" ?⋬)
573 ("\\ntriangleright" ?⋫)
574 ("\\ntrianglerighteq" ?⋭)
600 ("\\rangle" ?⟩) ;; Was ?〉, see bug#12948.
606 ("\\rightarrowtail" ?↣)
607 ("\\rightharpoondown" ?⇁)
608 ("\\rightharpoonup" ?⇀)
609 ("\\rightleftarrows" ?⇄)
610 ("\\rightleftharpoons" ?⇌)
611 ;; ("\\rightparengtr" ?⦔) ;; Was ?〉, see bug#12948.
612 ("\\rightrightarrows" ?⇉)
613 ("\\rightthreetimes" ?⋌)
614 ("\\risingdotseq" ?≓)
621 ("\\shortparallel" ?∥)
625 ("\\smallsetminus" ?∖)
629 ("\\sphericalangle" ?∢)
637 ("\\squigarrowright" ?⇝)
666 ("\\triangledown" ?▿)
667 ("\\triangleleft" ?◃)
668 ("\\trianglelefteq" ?⊴)
670 ("\\triangleright" ?▹)
671 ("\\trianglerighteq" ?⊵)
672 ("\\twoheadleftarrow" ?↞)
673 ("\\twoheadrightarrow" ?↠)
677 ("\\upleftharpoon" ?↿)
679 ("\\uprightharpoon" ?↾)
686 (concat "\\var" (downcase (match-string 1 name))))
687 "\\`GREEK \\([^- ]+\\) SYMBOL\\'")
691 ("\\varsigma" ?ς) ;FIXME: Looks reversed with the non\var.
692 ("\\vartriangleleft" ?⊲)
693 ("\\vartriangleright" ?⊳)
703 ("\\Bbb{N}" ?ℕ) ; AMS commands for blackboard bold
704 ("\\Bbb{P}" ?ℙ) ; Also sometimes \mathbb.
709 ;; We used to use ~ for NBSP but that's inconvenient and may even look like
710 ;; a bug where the user finds his ~ key doesn't insert a ~ any more.
713 ("\\mathscr{I}" ?ℐ) ; moment of inertia
719 ;; Probably not useful enough:
720 ;; ("\\Telefon" ?☎) ; there are other possibilities
721 ;; ("\\Radioactivity" ?☢)
725 ;; ("\\Lightning" ?☇)
734 ;; ("\\Writinghand" ?✍)
743 ("\\ordmasculine" ?º)
746 ;; by analogy with lq, rq:
749 ("\\defs" ?≙) ; per fuzz/zed
751 ("\\llbracket" ?\〚) ; stmaryrd
753 ;; ("\\lbag" ?\〚) ; fuzz
755 ("\\ldata" ?\《) ; fuzz/zed
757 ;; From Karl Eichwalder.
760 ("\\glqq" ?„) ("\\\"`" ?„)
761 ("\\grqq" ?“) ("\\\"'" ?“)
764 ("\\flqq" ?\«) ("\\\"<" ?\«)
765 ("\\frqq" ?\») ("\\\">" ?\»)
767 ("\\-" ?) ;; soft hyphen
770 ("\\textfractionsolidus" ?⁄)
771 ("\\textbigcircle" ?⃝)
772 ("\\textmusicalnote" ?♪)
774 ("\\textcolonmonetary" ?₡)
780 ("\\textinterrobang" ?‽)
781 ("\\textpertenthousand" ?‱)
784 ("\\textdiscount" ?⁒)
785 ("\\textestimated" ?℮)
786 ("\\textopenbullet" ?◦)
789 ("\\textcircledP" ?℗)
790 ("\\textreferencemark" ?※)
793 ;;; latin-ltx.el ends here