(chise-tex-encode-region-for-utf-8-jis): New optional argument
authorMORIOKA Tomohiko <tomo.git@chise.org>
Mon, 21 Feb 2011 20:50:32 +0000 (20:50 +0000)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Mon, 21 Feb 2011 20:50:32 +0000 (20:50 +0000)
`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

index 5a31d0c..e0256f5 100644 (file)
                 (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
            (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)
                   (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)))
                   (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))
    ))
 
 (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