From: MORIOKA Tomohiko Date: Wed, 20 Jan 2010 03:03:35 +0000 (+0000) Subject: (decompose-char): New function. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f9531ff139af52e1899061de2111d170ab51982;p=chise%2Fuptex-chise.git (decompose-char): New function. (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. --- diff --git a/elisp/chise-tex.el b/elisp/chise-tex.el index 5527325..041144d 100644 --- a/elisp/chise-tex.el +++ b/elisp/chise-tex.el @@ -24,6 +24,18 @@ ;;; 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) @@ -56,19 +68,27 @@ (thai-tis620 "ThaiTIS" 2 X) )) -(defvar chise-tex-accent-macro-alist +(defvar chise-tex-accents-macro-alist '((?\u0300 . "`") ; (?\u0301 . "'") ; (?\u0302 . "^") ; + ((?\u0302 ?\u0300) . "CircGrave") + ((?\u0302 ?\u0301) . ("\\'{\\^" . "}")) + ((?\u0302 ?\u0303) . ("\\~{\\^" . "}")) + ((?\u0302 ?\u0309) . "CircHook") (?\u0303 . "~") ; (?\u0304 . "=") ; + ((?\u0304 ?\u0301) . "textacutemacron") (?\u0306 . "u") ; (?\u0307 . ".") ; (?\u0308 . "\"") ; (?\u0309 . "Hook") (?\u030B . "H") ; (?\u030C . "v") ; + ((?\u031B ?\u0301) . "HornAcute") + ((?\u031B ?\u0303) . "HornTilde") (?\u0323 . "d") ; + ((?\u0323 ?\u0302) . "Circudot") (?\u0327 . "c") ; (?\u0328 . "k") ; (?\u032E . "ubreve") @@ -367,7 +387,9 @@ (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)) @@ -461,37 +483,55 @@ ) ((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 ; - (?\u0301 ; - . "\\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 ; + ;; (?\u0301 ; + ;; . "\\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)