emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] elpa 5beae62 25/35: Set the right coding systems for Japanese TeX


From: Tassilo Horn
Subject: [elpa] elpa 5beae62 25/35: Set the right coding systems for Japanese TeX process
Date: Thu, 1 Sep 2016 15:57:50 +0000 (UTC)

branch: elpa
commit 5beae6281041f9c6c1c9a88370615ad9ccf2d410
Author: Ikumi Keita <address@hidden>
Commit: Masayuki Ataka <address@hidden>

    Set the right coding systems for Japanese TeX process
    
    Set the right coding systems for Japanese TeX process
    
    * tex-jp.el:
    (LaTeX-command-style): Remove kanji option from uplatex and jlatex,
    which was there by mistake.
    (TeX-japanese-process-input-coding-system,
    TeX-japanese-process-output-coding-system,
    japanese-TeX-set-process-coding-system): The coding systems for
    interacting with Japanese TeX vary with the OS and other
    circumstances.  So choose the suitable coding system at run time
    rather than using the fixed values.
    (japanese-TeX-use-kanji-opt-flag): Declare before the first use.
    In addition, change default value and tailor doc string as per the
    above change.
    (japanese-TeX-coding-ejsu): Add coding system compatible for emacs
    21 and xemacs.
    
    Signed-off-by: Masayuki Ataka <address@hidden>
---
 tex-jp.el |  132 ++++++++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 101 insertions(+), 31 deletions(-)

diff --git a/tex-jp.el b/tex-jp.el
index a905348..cee4b2f 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -48,6 +48,14 @@
                 (const :tag "jTeX" jtex)
                 (const :tag "upTeX" uptex)))
 
+(defcustom japanese-TeX-use-kanji-opt-flag (not (eq system-type 'windows-nt))
+  "Add kanji option to Japanese pTeX family if non-nil.
+If `TeX-japanese-process-input-coding-system' or
+`TeX-japanese-process-output-coding-system' are non-nil, the process coding
+systems are determined by their values regardless of the kanji option."
+  :group 'AUCTeX-jp
+  :type 'boolean)
+
 (setq TeX-engine-alist-builtin
       (append TeX-engine-alist-builtin
              '((ptex "pTeX" "ptex %(kanjiopt)" "platex %(kanjiopt)" "eptex")
@@ -246,11 +254,11 @@ For detail, see `TeX-command-list', to which this list is 
appended."
 ;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (setq LaTeX-command-style
       (append '(("\\`u[jt]\\(article\\|report\\|book\\)\\'\\|\\`uplatex\\'"
-                "%(PDF)uplatex %(kanjiopt)%S%(PDFout)")
+                "%(PDF)uplatex %S%(PDFout)")
                ("\\`[jt]s?\\(article\\|report\\|book\\)\\'"
                 "%(PDF)platex %(kanjiopt)%S%(PDFout)")
                ("\\`j-\\(article\\|report\\|book\\)\\'"
-                "%(PDF)jlatex %(kanjiopt)%S%(PDFout)"))
+                "%(PDF)jlatex %S%(PDFout)"))
              LaTeX-command-style))
 
 (defcustom japanese-TeX-error-messages t
@@ -258,28 +266,19 @@ For detail, see `TeX-command-list', to which this list is 
appended."
   :group 'AUCTeX-jp
   :type 'boolean)
 
-;; FIX-ME (2007-02-09) The default coding system in recent Unix (like Fedora 
and
-;; Ubuntu) is utf-8.  But Japanese TeX system does not support utf-8 yet
-;; (platex-utf is under development, may be alpha phase).  So,
-;; process-coding-system for Japanese TeX is not defined from
-;; default-coding-system.  When platex-utf is out, we should look this setting,
-;; again.
-
-(defcustom TeX-japanese-process-input-coding-system
-  (cond ((memq system-type '(windows-nt ms-dos cygwin)) 'shift_jis-dos)
-       ((memq system-type '(mac darwin)) 'shift_jis-mac)
-       (t 'euc-jp-unix))
-  "TeX-process' coding system with standard input."
+(defcustom TeX-japanese-process-input-coding-system nil
+  "If non-nil, used for encoding input to Japanese TeX process.
+When nil, AUCTeX tries to choose suitable coding system.
+See also a user custom option `TeX-japanese-process-output-coding-system'."
   :group 'AUCTeX-jp
-  :type 'coding-system)
+  :type '(choice (const :tag "Default" nil) coding-system))
 
-(defcustom TeX-japanese-process-output-coding-system
-  (cond ((memq system-type '(windows-nt ms-dos cygwin)) 'shift_jis-dos)
-       ((memq system-type '(mac darwin)) 'shift_jis-mac)
-       (t 'euc-jp-unix))
-  "TeX-process' coding system with standard output."
+(defcustom TeX-japanese-process-output-coding-system nil
+  "If non-nil, used for decoding output from Japanese TeX process.
+When nil, AUCTeX tries to choose suitable coding system.
+See also a user custom option `TeX-japanese-process-input-coding-system'."
   :group 'AUCTeX-jp
-  :type 'coding-system)
+  :type '(choice (const :tag "Default" nil) coding-system))
 
 ;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (defcustom japanese-TeX-command-default "pTeX"
@@ -327,19 +326,81 @@ For detail, see `TeX-command-list', to which this list is 
appended."
 
 (defun japanese-TeX-set-process-coding-system (process)
   "Set proper coding system for japanese TeX PROCESS."
-  (if (with-current-buffer TeX-command-buffer japanese-TeX-mode)
-      (set-process-coding-system process
-                                TeX-japanese-process-output-coding-system
-                                TeX-japanese-process-input-coding-system)))
+  (with-current-buffer TeX-command-buffer
+    (when japanese-TeX-mode
+      ;; TeX-engine $B$,(B ptex, jtex, uptex 
$B$N$$$:$l$+$G$"$k>l9g$N$_9M$((B
+      ;; $B$k!#(Bluatex-ja $B$J$I$N>address@hidden(B latex-mode 
$B$G$h$/!"(B
+      ;; $B$o$6$o$6(B japanese-latex-mode $B$K$9$kI,MW$,$J$$!#(B
+
+      ;; FIXME: $B0J2<$N=hM}$O(B tex engine 
$B$rBP>]$H$9$k>l9g$7$+9M$($F$$$J$$!#(B
+      ;; bibtex $B$d(B mendex 
$BEy$NJd=u%D!<%k$N>address@hidden/$J$$=hM}$+$b$7$l$J$$!#(B
+      (let*
+         ;; -kanji $B%*%W%7%g%s$"$j$N;~$NJ8;z%3!<%I!#(B
+         ((kanji (and japanese-TeX-use-kanji-opt-flag
+                      (let ((str (japanese-TeX-get-encoding-string)))
+                        (cond
+                         ((equal str "euc") 'euc-jp)
+                         ((equal str "jis") 'iso-2022-jp)
+                         ((equal str "sjis") 'shift_jis)
+                         ((equal str "utf8") 'utf-8)))))
+
+          ;; process $B$+$i$N=PNO$NJ8;z%3!<%I!#(B
+          (dec (cond
+                ;; windows $B$H(B mac $B$N>l9g!#(B
+                ((memq system-type '(windows-nt darwin))
+                 (cond
+                  ;; ptex $B$J$i(B mac $B$O(B utf-8$B!#(B
+                  ;; windows $B$G(B -kanji 
$B%*%W%7%g%s$"$j$N;~$O$=$NJ8;z%3!<%I!"(B
+                  ;; $B$J$7$N;~$O(B sjis$B!#(B
+                  ((eq TeX-engine 'ptex)
+                   (cond ((eq system-type 'darwin)
+                          'utf-8)
+                         (japanese-TeX-use-kanji-opt-flag
+                          kanji)
+                         (t 'shift_jis)))
+                  ;; jtex $B$J$i(B sjis $B$K8GDj$9$k!#(B
+                  ((eq TeX-engine 'jtex)
+                   'shift_jis)
+                  ;; uptex $B$J$i(B utf-8 $B$K8GDj$9$k!#(B
+                  (t
+                   'utf-8)))
+                ;; unix $B$N>l9g!#(B
+                (t
+                 ;; jtex $B$J$i(B euc $B$K8GDj$9$k!#(B
+                 (cond
+                  ((eq TeX-engine 'jtex)
+                   'euc-jp)
+                  ;; $B$=$l0J30$O!"(Buptex $B$G$b(B locale $B$K=>$&!#(B
+                  ;; address@hidden"(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))))))
+
+          ;; process $B$KM?$($kF~NO$NJ8;z%3!<%I!#(B
+          (enc (cond
+                ;; ptex $B$G(B -kanji 
$B%*%W%7%g%s$"$j$J$i!"$=$NJ8;z%3!<%I!#(B
+                ;; $B$J$7$J$i(B utf-8 $B$+(B sjis$B!#(B
+                ((eq TeX-engine 'ptex)
+                 (if japanese-TeX-use-kanji-opt-flag
+                     kanji
+                   (if (eq system-type 'windows-nt)
+                       'shift_jis 'utf-8)))
+                ;; jtex $B$J$i(B euc $B$+(B sjis $B$K8GDj$9$k!#(B
+                ((eq TeX-engine 'jtex)
+                 (if (memq system-type '(windows-nt darwin))
+                     'shift_jis 'euc-jp))
+                ;; uptex $B$J$i(B utf-8 $B$K8GDj$9$k!#(B
+                (t
+                 'utf-8))))
+       ;; Customize $BCM$,$"address@hidden(B
+       (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))
 
-(defcustom japanese-TeX-use-kanji-opt-flag t
-  "Add kanji option to Japanese pTeX family if non-nil."
-  :group 'AUCTeX-jp
-  :type 'boolean)
-
 (defun japanese-TeX-coding-ejsu (coding-system)
   "Convert japanese CODING-SYSTEM to mnemonic string.
 euc-jp:    \"euc\"
@@ -348,17 +409,26 @@ shift_jis: \"sjis\"
 utf-8:     \"utf8\"
 Return nil otherwise."
   (let ((base (coding-system-base coding-system)))
+    (if (featurep 'xemacs)
+       (setq base (coding-system-name base)))
     (cdr (assq base
               '((japanese-iso-8bit . "euc")
+                (euc-jp . "euc") ; for xemacs
                 (iso-2022-jp . "jis")
                 (japanese-shift-jis . "sjis")
+                (shift_jis . "sjis") ; for xemacs
                 (utf-8 . "utf8")
+                (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 address@hidden<$NL>A0$O0c$&$+$b!D!#(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
                 (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"))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]