(chise-tex-encode-region-for-jis): New function.
authortomo <tomo>
Thu, 2 Sep 2004 14:25:41 +0000 (14:25 +0000)
committertomo <tomo>
Thu, 2 Sep 2004 14:25:41 +0000 (14:25 +0000)
(iso-2022-jp-tex-jis): New coding-system.

chise2otf/elisp/chise-tex.el

index 307e353..b580985 100644 (file)
                (t
                 (forward-char))))))))
 
+(defun chise-tex-encode-region-for-jis (start end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char start)
+      (let (chr ret rest spec)
+       (while (and (skip-chars-forward "\x00-\xFF")
+                   (not (eobp)))
+         (setq chr (char-after))
+          (cond ((encode-char chr '=jis-x0208-1983)
+                (forward-char))
+                ;; ((setq ret (encode-char chr '=jis-x0208-1990))
+                ;;  (delete-char)
+                ;;  (insert (decode-char '=jis-x0208-1983 ret)))
+               ((catch 'tag
+                  (setq rest chise-tex-coded-charset-expression-alist)
+                  (while (setq spec (car rest))
+                    (if (setq ret (encode-char chr (car spec)))
+                        (throw 'tag ret))
+                    (setq rest (cdr rest))))
+                (delete-char)
+                ;; (if (eq (char-before) ?\e$B!T\e(B)
+                ;;     (insert " "))
+                (insert (format (format "\\%s{%%0%d%s}"
+                                        (nth 1 spec)
+                                        (nth 2 spec)
+                                        (nth 3 spec))
+                                ret)))
+               (t
+                (forward-char))))))))
+
 (defun chise-tex-decode-region (start end)
   (interactive "r")
   (save-excursion
    mnemonic "pTeX(GB)/7bit"
    ))
 
+(make-coding-system
+ 'iso-2022-jp-tex-jis 'iso2022
+ "ISO-2022-JP with TeX representation for JIS fonts."
+ '(charset-g0 ascii
+   short t
+   seven t
+   input-charset-conversion ((latin-jisx0201 ascii)
+                            (japanese-jisx0208-1978 japanese-jisx0208))
+   pre-write-conversion chise-tex-encode-region-for-jis
+   post-read-conversion chise-tex-decode-region
+   mnemonic "pTeX(JIS)/7bit"
+   ))
+
 
 ;;; @ End.
 ;;;