From 3df3d8436e99e324086a98bdd6e3b5ca02946e0f Mon Sep 17 00:00:00 2001 From: MORIOKA Tomohiko Date: Mon, 21 Feb 2011 20:50:32 +0000 Subject: [PATCH] (chise-tex-encode-region-for-utf-8-jis): New optional argument `ptex-mode'; don't encode JIS X 0208:1990 characters as the same as JIS X 0208:1983 characters; don't use \UCSsip{hhhhh} when `ptex-mode' is t; don't encode JIS X 0213 characters when `ptex-mode' is nil. (chise-ptex-encode-region-for-utf-8-jis): New function. (chise-xetex-encode-region-for-utf-8-jis): Add local variable `rest' and `spec'. (utf-8-jp-ptex): New coding-system. --- elisp/chise-tex.el | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/elisp/chise-tex.el b/elisp/chise-tex.el index 5a31d0c..e0256f5 100644 --- a/elisp/chise-tex.el +++ b/elisp/chise-tex.el @@ -413,7 +413,7 @@ (t (forward-char)))))))) -(defun chise-tex-encode-region-for-utf-8-jis (start end) +(defun chise-tex-encode-region-for-utf-8-jis (start end &optional ptex-mode) (interactive "r") (save-excursion (save-restriction @@ -497,7 +497,9 @@ (cond ((eq (char-ucs chr) #x00D7) (delete-char) (insert "\\UCSjis{00D7}")) - ((encode-char chr '=jis-x0208-1983) + ((encode-char chr '=jis-x0208@1983) + (forward-char)) + ((encode-char chr '=jis-x0208@1990) (forward-char)) ((and (setq ret (char-ucs chr)) (or (eq ret #x00C5) @@ -546,12 +548,14 @@ (delete-char) (insert "\\oe{}") t) - ((and (setq ret (encode-char chr '=ucs@JP)) + ((and (not ptex-mode) + (setq ret (encode-char chr '=ucs@JP)) (>= ret #x20000)) (delete-char) (insert (format "\\UCSsip{%X}" ret)) t) - ((and (or (encode-char chr '=jis-x0213-1-2000) + ((and (not ptex-mode) + (or (encode-char chr '=jis-x0213-1-2000) (encode-char chr '=jis-x0213-2-2000)) (setq ret (or (encode-char chr '=ucs@jis/2000) (encode-char chr '=ucs@jis/fw))) @@ -565,13 +569,17 @@ (t (forward-char)))))))))) +(defun chise-ptex-encode-region-for-utf-8-jis (start end) + (interactive "r") + (chise-tex-encode-region-for-utf-8-jis start end 'ptex-mode)) + (defun chise-xetex-encode-region-for-utf-8-jis (start end) (interactive "r") (save-excursion (save-restriction (narrow-to-region start end) (goto-char start) - (let (chr ret) + (let (chr ret rest spec) (while (and (skip-chars-forward "\x00-\x7F") (not (eobp))) (setq chr (char-after)) @@ -719,6 +727,16 @@ )) (make-coding-system + 'utf-8-jp-ptex 'utf-8 + "Coding-system of UTF-8 for pLaTeX with common glyphs used in Japan." + '(pre-write-conversion chise-ptex-encode-region-for-utf-8-jis + post-read-conversion chise-tex-decode-region + charset-g0 =ucs@jp + charset-g1 =>ucs-jis + charset-g2 =>ucs + mnemonic "pTeX(JP)/UTF8")) + +(make-coding-system 'utf-8-jp-tex 'utf-8 "Coding-system of UTF-8 for upLaTeX with common glyphs used in Japan." '(pre-write-conversion chise-tex-encode-region-for-utf-8-jis -- 1.7.10.4