[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] Enable directory local variables for japanese-latex-mode
From: |
Ikumi Keita |
Subject: |
[AUCTeX-devel] Enable directory local variables for japanese-latex-mode |
Date: |
Sun, 24 Apr 2016 20:06:52 +0900 |
Hi AUCTeX developers,
I noticed recently that directory local variables are invalid in
`japanese-latex-mode'.
[Short summary of this mail]
Could you review the attached change and apply if it is OK?
[Detail]
First of all, I explain how to confirm that directory local variables
are invalid in `japanese-latex-mode'. You don't need Japanese tex
engines to try.
Put the following two files in an empty directory somewhere.
---- .dir-locals.el ---------------------------------------------
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((japanese-latex-mode
(TeX-PDF-from-DVI . "Dvipdfmx")))
-----------------------------------------------------------------
---- test.tex ---------------------------------------------------
\documentclass{jarticle}
\begin{document}
DUMMY TEXT
\end{document}
%%% Local Variables:
%%% mode: japanese-latex
%%% TeX-master: t
%%% End:
-----------------------------------------------------------------
Open test.tex with AUCTeX and you fill find that the value of
`TeX-PDF-from-DVI' is not "Dvipdfmx", unless you customized it so before
opening the file. The value of `file-local-variables-alist' is
((mode . japanese-latex)
(TeX-master . t))
, which tells that the entry in .dir-locals.el is skipped over when
parsing .dir-locals.el.
The reason is that `japanese-latex-mode' binds `major-mode' to
`latex-mode', not `japanese-latex-mode' (the reason for this is
explained later). However, editing .dir-locals.el to replace
`japanese-latex-mode' with `latex-mode' and re-opening test.tex ends up
with a strange result. The value of `TeX-PDF-from-DVI' is still not
"Dvipdfmx". The reason for that is a bit complicated.
This time the value of `file-local-variables-alist' is
((TeX-PDF-from-DVI . "Dvipdfmx")
(mode . japanese-latex)
(TeX-master . t))
and the entry in .dir-locals.el is recognized as expected. The point is
that the entry of the directory local variable comes before the
pseudo-variable `mode' entry. These entries are processed in this order
by `hack-local-variables-apply'. The mode specification does not match
the current `major-mode' of `latex-mode', so it is considered that the
major mode is not set correctly and `japanese-latex-mode' is called
again at this point. The function eventually calls
`kill-all-local-variables' in `VirTeX-common-initialization', which
kills the binding of the directory local variable processed before that.
It may seem that simple solution to these problems is to set
`major-mode' to `japanese-latex-mode' in the mode function (or its mode
hook). However, that would bring undesired side effects. The name
`latex-mode' is hard coded in several places of AUCTeX like "(eq
major-mode 'latex-mode)", "(memq major-mode '(doctex-mode latex-mode)"
and so on. By such piece of codes, `japanese-latex-mode' should simply
be regarded as `latex-mode'. So I think that the above solution is not
suitable.
The attached patch is my approach to these problems. The idea is to set
`major-mode' to `japanese-latex-mode' only temporarily, i.e. during the
process of local variables, using `hack-local-variables-hook' to reset
the mode name afterward.
The patch also includes a change so that `latex-mode' is considered as
parent mode of `japanese-latex-mode' in directory local variables. In
this way, we can write .dir-locals.el such as:
---- .dir-locals.el ---------------------------------------------
((latex-mode
(TeX-clean-confirm . nil))
(japanese-latex-mode
(TeX-PDF-from-DVI . "Dvipdfmx")))
-----------------------------------------------------------------
I.e., Japanese TeX specific settings can be separated from general
settings.
Similar changes are added for `japanese-plain-tex-mode', too.
Comments and suggestions are welcome.
Regards,
Ikumi Keita
enable-dir-local
Description: change proposed
- [AUCTeX-devel] Enable directory local variables for japanese-latex-mode,
Ikumi Keita <=