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
)
48 (defconst latin-ltx--mark-map
54 ;; ("HOOK ABOVE" . ??)
61 ("DOUBLE ACUTE" .
"H")
64 (defconst latin-ltx--mark-re
(regexp-opt (mapcar #'car latin-ltx--mark-map
)))
66 (defun latin-ltx--ascii-p (char)
67 (and (characterp char
) (< char
128)))
69 (defmacro latin-ltx--define-rules
(&rest rules
)
74 (`(,_
,(pred characterp
)) (push rule newrules
)) ;; Normal quail rule.
78 (dolist (pair (ucs-names))
79 (let ((name (car pair
))
81 (when (and (characterp char
) ;; Ignore char-ranges.
82 (string-match re name
))
83 (let ((keys (if (stringp seq
)
84 (replace-match seq nil nil name
)
85 (funcall seq name char
))))
88 (setq count
(1+ count
))
89 (push (list x char
) newrules
))
90 (setq count
(1+ count
))
91 (push (list keys char
) newrules
))))))
92 ;; (message "latin-ltx: %d mappings for %S" count re)
94 (setq newrules
(delete-dups newrules
))
95 (let ((rules (copy-sequence newrules
)))
97 (let ((rule (pop rules
)))
98 (when (assoc (car rule
) rules
)
99 (let ((conflicts (list (cadr rule
)))
102 (while (setq c
(assoc (car rule
) tail
))
103 (push (cadr c
) conflicts
)
104 (setq tail
(cdr (memq c tail
)))
105 (setq rules
(delq c rules
)))
106 (message "Conflict for %S: %S"
107 (car rule
) (apply #'string conflicts
)))))))
108 (let ((inputs (mapcar #'car newrules
)))
109 (setq inputs
(delete-dups inputs
))
110 (message "latin-ltx: %d rules (+ %d conflicts)!"
111 (length inputs
) (- (length newrules
) (length inputs
))))
112 `(quail-define-rules ,@(nreverse newrules
)))))
114 (latin-ltx--define-rules
116 ("\\pounds" ?£
) ;; ("{\\pounds}" ?£)
117 ("\\S" ?§
) ;; ("{\\S}" ?§)
119 ("$\\pm$" ?±
) ("\\pm" ?±
)
122 ("\\P" ?¶
) ;; ("{\\P}" ?¶)
123 ;; Fixme: Yudit has the equivalent of ("\\cdot" ?⋅), for U+22C5, DOT
124 ;; OPERATOR, whereas · is MIDDLE DOT. JadeTeX translates both to
126 ("$\\cdot$" ?·
) ("\\cdot" ?·
)
132 (let* ((c (if (match-end 1)
133 (downcase (match-string 2 name
))
134 (match-string 2 name
)))
135 (mark1 (cdr (assoc (match-string 3 name
) latin-ltx--mark-map
)))
136 (mark2 (if (match-end 4)
137 (cdr (assoc (match-string 4 name
) latin-ltx--mark-map
))))
138 (marks (if mark2
(concat mark1
"\\" mark2
) mark1
)))
140 (cons (format "\\%s{%s}" marks c
)
141 ;; Exclude "d" because we use "\\dh" for something else.
142 (unless (member (or mark2 mark1
) '("d"));; "k"
143 (list (format "\\%s%s" marks c
))))))
144 (concat "\\`LATIN \\(?:CAPITAL\\|SMAL\\(L\\)\\) LETTER \\(.\\) WITH \\("
145 latin-ltx--mark-re
"\\)\\(?: AND \\("
146 latin-ltx--mark-re
"\\)\\)?\\'"))
149 (let* ((mark (cdr (assoc (match-string 1 name
) latin-ltx--mark-map
))))
151 (list (format "\\%s" mark
))))
152 (concat "\\`COMBINING \\(" latin-ltx--mark-re
"\\)\\(?: ACCENT\\)?\\'"))
155 (unless (latin-ltx--ascii-p char
)
156 (let* ((mark (cdr (assoc (match-string 1 name
) latin-ltx--mark-map
))))
158 (list (format "\\%s{}" mark
)))))
159 (concat "\\`\\(?:SPACING \\)?\\(" latin-ltx--mark-re
"\\)\\(?: ACCENT\\)?\\'"))
161 ("\\AA" ?Å
) ;; ("{\\AA}" ?Å)
162 ("\\AE" ?Æ
) ;; ("{\\AE}" ?Æ)
164 ("$\\times$" ?×
) ("\\times" ?×
)
165 ("\\O" ?Ø
) ;; ("{\\O}" ?Ø)
166 ("\\ss" ?ß
) ;; ("{\\ss}" ?ß)
168 ("\\aa" ?å
) ;; ("{\\aa}" ?å)
169 ("\\ae" ?æ
) ;; ("{\\ae}" ?æ)
171 ("$\\div$" ?÷
) ("\\div" ?÷
)
172 ("\\o" ?ø
) ;; ("{\\o}" ?ø)
178 ("\\i" ?ı
) ;; ("{\\i}" ?ı)
181 ("\\L" ?Ł
) ;; ("{\\L}" ?Ł)
182 ("\\l" ?ł
) ;; ("{\\l}" ?ł)
186 ("\\U{o}" ?ő
) ("\\Uo" ?ő
) ;; FIXME: Was it just a typo?
188 ("\\OE" ?Œ
) ;; ("{\\OE}" ?Œ)
189 ("\\oe" ?œ
) ;; ("{\\oe}" ?œ)
193 ("\\={\\AE}" ?Ǣ
) ("\\=\\AE" ?Ǣ
)
194 ("\\={\\ae}" ?ǣ
) ("\\=\\ae" ?ǣ
)
197 ("\\'{\\AE}" ?Ǽ
) ("\\'\\AE" ?Ǽ
)
198 ("\\'{\\ae}" ?ǽ
) ("\\'\\ae" ?ǽ
)
199 ("\\'{\\O}" ?Ǿ
) ("\\'\\O" ?Ǿ
)
200 ("\\'{\\o}" ?ǿ
) ("\\'\\o" ?ǿ
)
208 (let* ((base (concat (match-string 1 name
) (match-string 3 name
)))
209 (basechar (cdr (assoc base
(ucs-names)))))
210 (when (latin-ltx--ascii-p basechar
)
211 (string (if (match-end 2) ?^ ?_
) basechar
))))
212 "\\(.*\\)SU\\(?:B\\|\\(PER\\)\\)SCRIPT \\(.*\\)")
214 ((lambda (name _char
)
215 (let* ((basename (match-string 2 name
))
216 (name (if (match-end 1) (capitalize basename
) (downcase basename
))))
217 (concat "^" (if (> (length name
) 1) "\\") name
)))
218 "\\`MODIFIER LETTER \\(?:SMALL\\|CAPITA\\(L\\)\\) \\([[:ascii:]]+\\)\\'")
220 ;; ((lambda (name char) (format "^%s" (downcase (match-string 1 name))))
221 ;; "\\`MODIFIER LETTER SMALL \\(.\\)\\'")
222 ;; ("^\\1" "\\`MODIFIER LETTER CAPITAL \\(.\\)\\'")
232 ;; FIXME: Provides some useful entries (yen, euro, copyright, registered,
233 ;; currency, minus, micro), but also a lot of dubious ones.
235 (unless (or (latin-ltx--ascii-p char
)
236 ;; We prefer COMBINING LONG SOLIDUS OVERLAY for \not.
237 (member name
'("NOT SIGN")))
238 (concat "\\" (downcase (match-string 1 name
)))))
239 "\\`\\([^- ]+\\) SIGN\\'")
242 (concat "\\" (funcall (if (match-end 1) #' capitalize
#'downcase
)
243 (match-string 2 name
))))
244 "\\`GREEK \\(?:SMALL\\|CAPITA\\(L\\)\\) LETTER \\([^- ]+\\)\\'")
256 ("\\Leftrightarrow" ?⇔
)
259 ("\\Longleftarrow" ?⇐
)
260 ("\\Longleftrightarrow" ?⇔
)
261 ("\\Longrightarrow" ?⇒
)
295 ("\\bigtriangledown" ?▽
)
296 ("\\bigtriangleup" ?△
)
299 ("\\blacklozenge" ?✦
)
301 ("\\blacktriangle" ?▴
)
302 ("\\blacktriangledown" ?▾
)
303 ("\\blacktriangleleft" ?◂
)
304 ("\\blacktriangleright" ?▸
)
319 ("\\circlearrowleft" ?↺
)
320 ("\\circlearrowright" ?↻
)
337 ("\\curvearrowleft" ?↶
)
338 ("\\curvearrowright" ?↷
)
349 ("\\divideontimes" ?⋇
)
355 ("\\downdownarrows" ?⇊
)
356 ("\\downleftharpoon" ?⇃
)
357 ("\\downrightharpoon" ?⇂
)
366 ("\\fallingdotseq" ?≒
)
407 ("\\hookleftarrow" ?↩
)
408 ("\\hookrightarrow" ?↪
)
415 ("\\langle" ?⟨
) ;; Was ?〈, see bug#12948.
423 ("\\leftarrowtail" ?↢
)
424 ("\\leftharpoondown" ?↽
)
425 ("\\leftharpoonup" ?↼
)
426 ("\\leftleftarrows" ?⇇
)
427 ;; ("\\leftparengtr" ?〈), see bug#12948.
428 ("\\leftrightarrow" ?↔
)
429 ("\\leftrightarrows" ?⇆
)
430 ("\\leftrightharpoons" ?⇋
)
431 ("\\leftrightsquigarrow" ?↭
)
432 ("\\leftthreetimes" ?⋋
)
451 ("\\longleftarrow" ?←
)
452 ("\\longleftrightarrow" ?↔
)
454 ("\\longrightarrow" ?→
)
455 ("\\looparrowleft" ?↫
)
456 ("\\looparrowright" ?↬
)
464 ("\\measuredangle" ?∡
)
471 ("\\nLeftrightarrow" ?⇎
)
492 ("\\nleftrightarrow" ?↮
)
498 ("\\not" ?̸
) ;FIXME: conflict with "NOT SIGN" ¬.
505 ("\\nshortparallel" ?∦
)
516 ("\\ntriangleleft" ?⋪
)
517 ("\\ntrianglelefteq" ?⋬
)
518 ("\\ntriangleright" ?⋫
)
519 ("\\ntrianglerighteq" ?⋭
)
545 ("\\rangle" ?⟩
) ;; Was ?〉, see bug#12948.
551 ("\\rightarrowtail" ?↣
)
552 ("\\rightharpoondown" ?⇁
)
553 ("\\rightharpoonup" ?⇀
)
554 ("\\rightleftarrows" ?⇄
)
555 ("\\rightleftharpoons" ?⇌
)
556 ;; ("\\rightparengtr" ?⦔) ;; Was ?〉, see bug#12948.
557 ("\\rightrightarrows" ?⇉
)
558 ("\\rightthreetimes" ?⋌
)
559 ("\\risingdotseq" ?≓
)
566 ("\\shortparallel" ?∥
)
570 ("\\smallsetminus" ?∖
)
574 ("\\sphericalangle" ?∢
)
582 ("\\squigarrowright" ?⇝
)
611 ("\\triangledown" ?▿
)
612 ("\\triangleleft" ?◃
)
613 ("\\trianglelefteq" ?⊴
)
615 ("\\triangleright" ?▹
)
616 ("\\trianglerighteq" ?⊵
)
617 ("\\twoheadleftarrow" ?↞
)
618 ("\\twoheadrightarrow" ?↠
)
622 ("\\upleftharpoon" ?↿
)
624 ("\\uprightharpoon" ?↾
)
631 (concat "\\var" (downcase (match-string 1 name
))))
632 "\\`GREEK \\([^- ]+\\) SYMBOL\\'")
636 ("\\varsigma" ?ς
) ;FIXME: Looks reversed with the non\var.
637 ("\\vartriangleleft" ?⊲
)
638 ("\\vartriangleright" ?⊳
)
648 ("\\Bbb{N}" ?ℕ
) ; AMS commands for blackboard bold
649 ("\\Bbb{P}" ?ℙ
) ; Also sometimes \mathbb.
654 ;; We used to use ~ for NBSP but that's inconvenient and may even look like
655 ;; a bug where the user finds his ~ key doesn't insert a ~ any more.
658 ("\\mathscr{I}" ?ℐ
) ; moment of inertia
664 ;; Probably not useful enough:
665 ;; ("\\Telefon" ?☎) ; there are other possibilities
666 ;; ("\\Radioactivity" ?☢)
670 ;; ("\\Lightning" ?☇)
679 ;; ("\\Writinghand" ?✍)
688 ("\\ordmasculine" ?º
)
691 ;; by analogy with lq, rq:
694 ("\\defs" ?≙
) ; per fuzz/zed
696 ("\\llbracket" ?\〚
) ; stmaryrd
698 ;; ("\\lbag" ?\〚) ; fuzz
700 ("\\ldata" ?\《
) ; fuzz/zed
702 ;; From Karl Eichwalder.
705 ("\\glqq" ?„
) ("\\\"`" ?„
)
706 ("\\grqq" ?“
) ("\\\"'" ?“
)
709 ("\\flqq" ?\«
) ("\\\"<" ?\«
)
710 ("\\frqq" ?\»
) ("\\\">" ?\»
)
712 ("\\-" ?
) ;; soft hyphen
715 ("\\textfractionsolidus" ?⁄
)
716 ("\\textbigcircle" ?⃝
)
717 ("\\textmusicalnote" ?♪
)
719 ("\\textcolonmonetary" ?₡
)
725 ("\\textinterrobang" ?‽
)
726 ("\\textpertenthousand" ?‱
)
729 ("\\textdiscount" ?⁒
)
730 ("\\textestimated" ?℮
)
731 ("\\textopenbullet" ?◦
)
734 ("\\textcircledP" ?℗
)
735 ("\\textreferencemark" ?※
)
738 ;;; latin-ltx.el ends here