(decompose-char): New function.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 20 Jan 2010 03:03:35 +0000 (03:03 +0000)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 20 Jan 2010 03:03:35 +0000 (03:03 +0000)
(chise-tex-accents-macro-alist): Renamed from
`chise-tex-accent-macro-alist'; add some compound accents entries.
(chise-tex-encode-region-for-utf-8-jis): Omit local variable
`modifier-1'; use `decompose-char'; use
`chise-tex-accents-macro-alist' to avoid hard-coded codes.

elisp/chise-tex.el

index 5527325..041144d 100644 (file)
 
 ;;; Code:
 
+(defun decompose-char (char)
+  (let (ret dest)
+    (while (setq ret (char-feature char '=decomposition))
+      (setq dest
+           (if (cddr ret)
+               (append (cdr ret) dest)
+             (cons (nth 1 ret) dest))
+           char (car ret)))
+    (if dest
+       (cons char dest)
+      char)))
+
 (defvar chise-tex-coded-charset-expression-alist
   '((=ucs-bmp@gb       "UCSgb"         4 X)
     (=ucs-bmp@jis      "UCSjis"        4 X)
     (thai-tis620       "ThaiTIS"       2 X)
     ))
 
-(defvar chise-tex-accent-macro-alist
+(defvar chise-tex-accents-macro-alist
   '((?\u0300 . "`") ; <COMBINING GRAVE ACCENT>
     (?\u0301 . "'") ; <COMBINING ACUTE ACCENT>
     (?\u0302 . "^") ; <COMBINING CIRCUMFLEX ACCENT>
+    ((?\u0302 ?\u0300) . "CircGrave")
+    ((?\u0302 ?\u0301) . ("\\'{\\^" . "}"))
+    ((?\u0302 ?\u0303) . ("\\~{\\^" . "}"))
+    ((?\u0302 ?\u0309) . "CircHook")
     (?\u0303 . "~") ; <COMBINING TILDE>
     (?\u0304 . "=") ; <COMBINING MACRON>
+    ((?\u0304 ?\u0301) . "textacutemacron")
     (?\u0306 . "u") ; <COMBINING BREVE>
     (?\u0307 . ".") ; <COMBINING DOT ABOVE>
     (?\u0308 . "\"") ; <COMBINING DIAERESIS>
     (?\u0309 . "Hook")
     (?\u030B . "H") ; <COMBINING DOUBLE ACUTE ACCENT>
     (?\u030C . "v") ; <COMBINING CARON>
+    ((?\u031B ?\u0301) . "HornAcute")
+    ((?\u031B ?\u0303) . "HornTilde")
     (?\u0323 . "d") ; <COMBINING DOT BELOW>
+    ((?\u0323 ?\u0302) . "Circudot")
     (?\u0327 . "c") ; <COMBINING CEDILLA>
     (?\u0328 . "k") ; <COMBINING OGONEK>
     (?\u032E . "ubreve")
       (let ((font-encoding 'T1)
            chr ret
            ;; rest spec
-           modifier base modifier-1 pos)
+           modifier base
+            ;; modifier-1
+           pos)
        (while (and (skip-chars-forward "\x00-\x7F")
                    (not (eobp)))
          (setq chr (char-after))
                   )
                  ((and (not (eq (char-ucs chr) #x0439))
                        (not (eq (char-ucs chr) #x0451))
-                       (setq ret (char-feature chr '=decomposition))
-                       (setq modifier (assq (nth 1 ret)
-                                            chise-tex-accent-macro-alist)))
-                  (delete-char)
+                       (listp (setq ret (decompose-char chr)))
+                       ;; (setq ret (char-feature chr '=decomposition))
+                       (setq modifier (cdr ret))
+                        ;; (setq modifier (assq (nth 1 ret)
+                        ;;                      chise-tex-accent-macro-alist))
+                       )
+                   ;; (delete-char)
                   (setq base (car ret))
-                  (if (and (setq ret (char-feature base '=decomposition))
-                           (setq modifier-1
-                                 (assq
-                                  (car modifier)
-                                  (cdr
-                                   (assq
-                                    (nth 1 ret)
-                                    '((?\u0302
-                                       (?\u0300 . "\\CircGrave{%c}")
-                                       (?\u0301 . "\\'{\\^%c}")
-                                       (?\u0303 . "\\~{\\^%c}")
-                                       (?\u0309 . "\\CircHook{%c}")
-                                       )
-                                      (?\u0304 ; <COMBINING MACRON>
-                                       (?\u0301 ; <COMBINING ACUTE ACCENT>
-                                        . "\\textacutemacron{%c}")
-                                       )
-                                      (?\u031B
-                                       (?\u0301 . "\\HornAcute{%c}")
-                                       (?\u0303 . "\\HornTilde{%c}")
-                                       )
-                                      (?\u0323
-                                       (?\u0302 . "\\Circudot{%c}")
-                                       )))))))
-                      (insert (format (cdr modifier-1) (car ret)))
-                    (insert (format "\\%s{%c}" (cdr modifier) base))))
+                  (if (setq ret
+                            (if (cdr modifier)
+                                (assoc modifier
+                                       chise-tex-accents-macro-alist)
+                              (assq (car modifier)
+                                    chise-tex-accents-macro-alist)))
+                      (progn
+                        (delete-char)
+                        (setq ret (cdr ret))
+                        (if (consp ret)
+                            (insert (format "%s%c%s"
+                                            (car ret) base (cdr ret)))
+                          (insert (format "\\%s{%c}" ret base))))
+                    (forward-char))
+                   ;; (if (and (setq ret (char-feature base '=decomposition))
+                   ;;          (setq modifier-1
+                   ;;                (assq
+                   ;;                 (car modifier)
+                   ;;                 (cdr
+                   ;;                  (assq
+                   ;;                   (nth 1 ret)
+                   ;;                   '((?\u0302
+                   ;;                      (?\u0300 . "\\CircGrave{%c}")
+                   ;;                      (?\u0301 . "\\'{\\^%c}")
+                   ;;                      (?\u0303 . "\\~{\\^%c}")
+                   ;;                      (?\u0309 . "\\CircHook{%c}")
+                   ;;                      )
+                   ;;                     (?\u0304 ; <COMBINING MACRON>
+                   ;;                      (?\u0301 ; <COMBINING ACUTE ACCENT>
+                   ;;                       . "\\textacutemacron{%c}")
+                   ;;                      )
+                   ;;                     (?\u031B
+                   ;;                      (?\u0301 . "\\HornAcute{%c}")
+                   ;;                      (?\u0303 . "\\HornTilde{%c}")
+                   ;;                      )
+                   ;;                     (?\u0323
+                   ;;                      (?\u0302 . "\\Circudot{%c}")
+                   ;;                      )))))))
+                   ;;     (insert (format (cdr modifier-1) (car ret)))
+                   ;;   (insert (format "\\%s{%c}" (cdr modifier) base)))
+                  )
                  ((and (or (encode-char chr '=jis-x0213-1-2000)
                            (encode-char chr '=jis-x0213-2-2000))
                        (setq ret (or (encode-char chr '=ucs@jis/2000)