branch: externals/auctex
commit de5e40bebde353537f66e62385f235a815d506e2
Author: Ikumi Keita <ik...@ikumi.que.jp>
Commit: Ikumi Keita <ik...@ikumi.que.jp>

    Fix setting of coding system for Japanese TeX
    
    * tex-jp.el (japanese-TeX-set-process-coding-system): Cater for the
    case that kanji option is requested by user but cannot be determined.
    XEmacs doesn't have `locale-coding-system'.  Use
    `get-coding-system-from-locale' and `current-locale' instead.
    Cleanup indentation.
    (japanese-TeX-coding-ejsu): Add entry for xemacs coding system of cp932.
---
 tex-jp.el | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/tex-jp.el b/tex-jp.el
index e08d702..0a51126 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -358,7 +358,7 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
                   ((eq TeX-engine 'ptex)
                    (cond ((eq system-type 'darwin)
                           'utf-8)
-                         (japanese-TeX-use-kanji-opt-flag
+                         ((and japanese-TeX-use-kanji-opt-flag kanji)
                           kanji)
                          (t 'shift_jis)))
                   ;; jtex $B$J$i(B sjis $B$K8GDj$9$k!#(B
@@ -377,8 +377,23 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
                   ;; $B$?$@$7!"(Blocale $B$,F|K\8l$r%5%]!<%H$7$J$$>l9g$O(B
                   ;; euc $B$K8GDj$9$k!#(B
                   (t
-                   (if (japanese-TeX-coding-ejsu locale-coding-system)
-                       locale-coding-system 'euc-jp))))))
+                   (let ((lcs
+                          (cond
+                           ((boundp 'locale-coding-system)
+                            locale-coding-system)
+                           ;; XEmacs doesn't have `locale-coding-system'.
+                           ;; Instead xemacs 21.5 has
+                           ;; `get-coding-system-from-locale' and
+                           ;; `current-locale'.  They aren't available on
+                           ;; xemacs 21.4.
+                           ((and
+                             (featurep 'xemacs)
+                             (fboundp 'get-coding-system-from-locale)
+                             (fboundp 'current-locale))
+                            (get-coding-system-from-locale
+                             (current-locale))))))
+                     (if (and lcs (japanese-TeX-coding-ejsu lcs))
+                         lcs 'euc-jp)))))))
 
           ;; process $B$KM?$($kF~NO$NJ8;z%3!<%I!#(B
           (enc (cond
@@ -397,9 +412,10 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
                 (t
                  'utf-8))))
        ;; Customize $BCM$,$"$l$P$=$l$rM%@h!#(B
-       (set-process-coding-system process
-                                  (or 
TeX-japanese-process-output-coding-system dec)
-                                  (or TeX-japanese-process-input-coding-system 
enc))))))
+       (set-process-coding-system
+        process
+        (or TeX-japanese-process-output-coding-system dec)
+        (or TeX-japanese-process-input-coding-system enc))))))
 (when (featurep 'mule)
   (setq TeX-after-start-process-function
         #'japanese-TeX-set-process-coding-system))
@@ -424,16 +440,16 @@ Return nil otherwise."
                 (mule-utf-8 . "utf8") ; for emacs 21, 22
                 ;; utf-8-auto $B$d(B utf-8-emacs 
$B$rF~$l$kI,MW$O$"$k$N$+!)(B
 
-                ;; xemacs $B$G(B jisx0213 $B$O;H$($k$N$+!);H$($k$H$7$F!"(B
-                ;; $B$=$N(B coding system $BL>$O!)(B
+                ;; xemacs 21.5 with mule $B$K$O!"(Bjisx0213 $B$N(B charset 
$B$O(B
+                ;; $B$"$k$,$=$lMQ$N(B coding system $B$O$J$$!#(B
                 (euc-jis-2004 . "euc")
                 (iso-2022-jp-2004 . "jis")
                 (japanese-shift-jis-2004 . "sjis")
 
-                ;; xemacs $B$K(B cp932 $B7O$N(B coding system 
$B$,$"$k$N$+(B
-                ;; $B$I$&$+$b$h$/$o$+$i$J$$!#(B
                 (japanese-cp932 . "sjis")
-                (eucjp-ms . "euc"))))))
+                (eucjp-ms . "euc")
+                (windows-932 . "sjis") ; for xemacs 21.5 with mule
+               )))))
 
 (defun japanese-TeX-get-encoding-string ()
   "Return coding option string for Japanese pTeX family.

Reply via email to