branch: externals/auctex
commit ff0754463f2e5b916c0c05d10660313680eafb58
Author: Ikumi Keita <[email protected]>
Commit: Ikumi Keita <[email protected]>
Delay setting Japanese TeX engine in `japanese-latex-mode'
* tex-jp.el (japanese-latex-mode-initialization): The part which
guesses and sets `TeX-engine' using `TeX-match-style' is factored out
and put in `TeX-update-style-hook'. `TeX-match-style' eventually
triggers `TeX-update-style', which isn't appropriate in
`LaTeX-mode-hook'.
(japanese-LaTeX-guess-engine): New function.
---
tex-jp.el | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/tex-jp.el b/tex-jp.el
index 09909ba..b1663db 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -526,7 +526,6 @@ Set `japanese-TeX-mode' to t, and enter
`TeX-plain-tex-mode'."
(defun japanese-plain-tex-mode-initialization ()
"Japanese plain-TeX specific initializations."
(when japanese-TeX-mode
-; (setq TeX-command-default japanese-TeX-command-default)
(TeX-engine-set japanese-TeX-engine-default)
;; For the intent of the following lines, see the comments below
@@ -549,21 +548,16 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'."
(defun japanese-latex-mode-initialization ()
"Japanese LaTeX specific initializations."
(when japanese-TeX-mode
-; (setq TeX-command-default japanese-LaTeX-command-default)
- (TeX-engine-set
- (cond
- ((TeX-match-style "\\`u[jt]\\(article\\|report\\|book\\)\\'")
- 'uptex)
- ((TeX-match-style "\\`[jt]s?\\(article\\|report\\|book\\)\\'")
- (if (LaTeX-match-class-option "\\`uplatex\\'")
- 'uptex 'ptex))
- ((TeX-match-style "\\`j-\\(article\\|report\\|book\\)\\'")
- 'jtex)
- (t japanese-TeX-engine-default)))
+ ;; `TeX-match-style' $B$r;H$&$N$O(B `TeX-update-style'
$B$N8e$KCY$i$;$k!#(B
+ ;; $B$3$NCJ3,$G;H$&$H!"$=$NCf$G8F$V(B `TeX-style-list' $B$NCf$G(B
+ ;; `TeX-update-style' $B$,8F$P$l$F$7$^$$!"(Blocal variable
$BEy$N=`Hw$,(B
+ ;; $B@0$C$F$J$$CJ3,$G(B style hook
$B$,<B9T$5$l$FITE,$J7k2L$K$J$k$3$H$,(B
+ ;; $B$"$k!#$^$?!"(B`TeX-update-style' $B$O8e$+$i(B `find-file-hook'
$BCf$G$b(B
+ ;; $B$&0lEY8F$P$l$k$N$G!"(B`TeX-parse-self' $B$,(B t $B$@$H(B parse
$B=hM}$bL5BL(B
+ ;; $B$K(B 2 $B2s9T$o$l$F$7$^$&!#(B
+ (add-hook 'TeX-update-style-hook
+ #'japanese-LaTeX-guess-engine nil t)
(setq LaTeX-default-style japanese-LaTeX-default-style)
-; (setq TeX-command-BibTeX
-; (if (and (eq TeX-engine 'ptex) (executable-find "pbibtex"))
-; "pBibTeX" "jBibTeX"))
(when (and (fboundp 'font-latex-add-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
@@ -609,6 +603,25 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'."
(put 'japanese-plain-tex-mode 'derived-mode-parent 'plain-tex-mode)
(put 'japanese-latex-mode 'derived-mode-parent 'latex-mode)
+(defun japanese-LaTeX-guess-engine ()
+ "Guess Japanese TeX engine and set it to `TeX-engine'.
+Document class and its option is considered in the guess. Do not
+overwrite the value already set locally."
+ ;; `TeX-engine' may be set by the file local variable or by the menu
+ ;; Command->TeXing Options manually. Don't override the user
+ ;; preference set in such ways.
+ (unless (local-variable-p 'TeX-engine (current-buffer))
+ (TeX-engine-set
+ (cond
+ ((TeX-match-style "\\`u[jt]\\(?:article\\|report\\|book\\)\\'")
+ 'uptex)
+ ((TeX-match-style "\\`[jt]s?\\(?:article\\|report\\|book\\)\\'")
+ (if (LaTeX-match-class-option "\\`uplatex\\'")
+ 'uptex 'ptex))
+ ((TeX-match-style "\\`j-\\(?:article\\|report\\|book\\)\\'")
+ 'jtex)
+ (t japanese-TeX-engine-default)))))
+
;;; Support for various self-insert-command
(fset 'japanese-TeX-self-insert-command