1 ;;; latin-ltx.el --- Quail package for TeX-style input -*-coding: utf-8;-*-
3 ;; Copyright (C) 2001-2012 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 \\(.*\\)")
254 (let* ((base (format "LATIN %s LETTER %s"
255 (match-string 1 name) (match-string 2 name)))
256 (basechar (cdr (assoc base (ucs-names)))))
257 (when (latin-ltx--ascii-p basechar)
258 (string ?^ basechar))))
259 "MODIFIER LETTER \\(SMALL\\|CAPITAL\\) \\(.*\\)")
261 ;; ((lambda (name char) (format "^%s" (downcase (match-string 1 name))))
262 ;; "\\`MODIFIER LETTER SMALL \\(.\\)\\'")
263 ;; ("^\\1" "\\`MODIFIER LETTER CAPITAL \\(.\\)\\'")
272 ;; ("\\d{}" ?) ;; FIXME: can't find the DOT BELOW character.
274 (let ((c (if (match-end 1)
275 (downcase (match-string 2 name))
276 (match-string 2 name))))
277 (list (format "\\d{%s}" c) ;; (format "\\d%s" c)
279 "\\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH DOT BELOW")
283 ;; FIXME: Provides some useful entries (yen, euro, copyright, registered,
284 ;; currency, minus, micro), but also a lot of dubious ones.
286 (unless (latin-ltx--ascii-p char)
287 (concat "\\" (downcase (match-string 1 name)))))
288 "\\`\\([^- ]+\\) SIGN\\'")
291 (concat "\\" (funcall (if (match-end 1) #' capitalize #'downcase)
292 (match-string 2 name))))
293 "\\`GREEK \\(?:SMALL\\|CAPITA\\(L\\)\\) LETTER \\([^- ]+\\)\\'")
305 ("\\Leftrightarrow" ?⇔)
308 ("\\Longleftarrow" ?⇐)
309 ("\\Longleftrightarrow" ?⇔)
310 ("\\Longrightarrow" ?⇒)
344 ("\\bigtriangledown" ?▽)
345 ("\\bigtriangleup" ?△)
348 ("\\blacklozenge" ?✦)
350 ("\\blacktriangle" ?▴)
351 ("\\blacktriangledown" ?▾)
352 ("\\blacktriangleleft" ?◂)
353 ("\\blacktriangleright" ?▸)
368 ("\\circlearrowleft" ?↺)
369 ("\\circlearrowright" ?↻)
376 ("\\colon" ?:) ;FIXME: Conflict with "COLON SIGN" ₡.
387 ("\\curvearrowleft" ?↶)
388 ("\\curvearrowright" ?↷)
400 ("\\divideontimes" ?⋇)
406 ("\\downdownarrows" ?⇊)
407 ("\\downleftharpoon" ?⇃)
408 ("\\downrightharpoon" ?⇂)
417 ("\\fallingdotseq" ?≒)
458 ("\\hookleftarrow" ?↩)
459 ("\\hookrightarrow" ?↪)
474 ("\\leftarrowtail" ?↢)
475 ("\\leftharpoondown" ?↽)
476 ("\\leftharpoonup" ?↼)
477 ("\\leftleftarrows" ?⇇)
478 ("\\leftparengtr" ?〈)
479 ("\\leftrightarrow" ?↔)
480 ("\\leftrightarrows" ?⇆)
481 ("\\leftrightharpoons" ?⇋)
482 ("\\leftrightsquigarrow" ?↭)
483 ("\\leftthreetimes" ?⋋)
502 ("\\longleftarrow" ?←)
503 ("\\longleftrightarrow" ?↔)
505 ("\\longrightarrow" ?→)
506 ("\\looparrowleft" ?↫)
507 ("\\looparrowright" ?↬)
515 ("\\measuredangle" ?∡)
522 ("\\nLeftrightarrow" ?⇎)
543 ("\\nleftrightarrow" ?↮)
549 ("\\not" ?̸) ;FIXME: conflict with "NOT SIGN" ¬.
556 ("\\nshortparallel" ?∦)
567 ("\\ntriangleleft" ?⋪)
568 ("\\ntrianglelefteq" ?⋬)
569 ("\\ntriangleright" ?⋫)
570 ("\\ntrianglerighteq" ?⋭)
602 ("\\rightarrowtail" ?↣)
603 ("\\rightharpoondown" ?⇁)
604 ("\\rightharpoonup" ?⇀)
605 ("\\rightleftarrows" ?⇄)
606 ("\\rightleftharpoons" ?⇌)
607 ("\\rightparengtr" ?〉)
608 ("\\rightrightarrows" ?⇉)
609 ("\\rightthreetimes" ?⋌)
610 ("\\risingdotseq" ?≓)
617 ("\\shortparallel" ?∥)
621 ("\\smallsetminus" ?∖)
625 ("\\sphericalangle" ?∢)
633 ("\\squigarrowright" ?⇝)
662 ("\\triangledown" ?▿)
663 ("\\triangleleft" ?◃)
664 ("\\trianglelefteq" ?⊴)
666 ("\\triangleright" ?▹)
667 ("\\trianglerighteq" ?⊵)
668 ("\\twoheadleftarrow" ?↞)
669 ("\\twoheadrightarrow" ?↠)
673 ("\\upleftharpoon" ?↿)
675 ("\\uprightharpoon" ?↾)
682 (concat "\\var" (downcase (match-string 1 name))))
683 "\\`GREEK \\([^- ]+\\) SYMBOL\\'")
687 ("\\varsigma" ?ς) ;FIXME: Looks reversed with the non\var.
688 ("\\vartriangleleft" ?⊲)
689 ("\\vartriangleright" ?⊳)
699 ("\\Bbb{N}" ?ℕ) ; AMS commands for blackboard bold
700 ("\\Bbb{P}" ?ℙ) ; Also sometimes \mathbb.
705 ;; We used to use ~ for NBSP but that's inconvenient and may even look like
706 ;; a bug where the user finds his ~ key doesn't insert a ~ any more.
709 ("\\mathscr{I}" ?ℐ) ; moment of inertia
715 ;; Probably not useful enough:
716 ;; ("\\Telefon" ?☎) ; there are other possibilities
717 ;; ("\\Radioactivity" ?☢)
721 ;; ("\\Lightning" ?☇)
730 ;; ("\\Writinghand" ?✍)
739 ("\\ordmasculine" ?º)
742 ;; by analogy with lq, rq:
745 ("\\defs" ?≙) ; per fuzz/zed
747 ("\\llbracket" ?\〚) ; stmaryrd
749 ;; ("\\lbag" ?\〚) ; fuzz
751 ("\\ldata" ?\《) ; fuzz/zed
753 ;; From Karl Eichwalder.
756 ("\\glqq" ?„) ("\\\"`" ?„)
757 ("\\grqq" ?“) ("\\\"'" ?“)
760 ("\\flqq" ?\«) ("\\\"<" ?\«)
761 ("\\frqq" ?\») ("\\\">" ?\»)
763 ("\\-" ?) ;; soft hyphen
766 ("\\textfractionsolidus" ?⁄)
767 ("\\textbigcircle" ?⃝)
768 ("\\textmusicalnote" ?♪)
770 ("\\textcolonmonetary" ?₡)
776 ("\\textinterrobang" ?‽)
777 ("\\textpertenthousand" ?‱)
780 ("\\textdiscount" ?⁒)
781 ("\\textestimated" ?℮)
782 ("\\textopenbullet" ?◦)
785 ("\\textcircledP" ?℗)
786 ("\\textreferencemark" ?※)
789 ;;; latin-ltx.el ends here