auctex-devel
[Top][All Lists]
Advanced

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

Dependency on tex-buf.el


From: Ikumi Keita
Subject: Dependency on tex-buf.el
Date: Fri, 18 Mar 2022 18:06:24 +0900

Hi all,

There is a small inconsistency with respect to the dependency on
tex-buf.el in current AUCTeX.

[How to confirm]
0. Disable preview-latex and tool bar mode in init.el and start a new
   emacs session.
1. Open a LaTeX document, say, circ.tex.
2. Before invoking any external process, open a Texinfo document, say,
   copying.texi.
3. Switch to the LaTeX document buffer. Then the value of
   `TeX-sentinel-default-function' is `TeX-TeX-sentinel', not
   `TeX-LaTeX-sentinel'. This means that AUCTeX doesn't provide LaTeX
   specific support for typesetting. For example, if the document is
   circ.tex, AUCTeX just displays
LaTeX: formatted {5} pages
   after C-c C-c finishes, not
You should run LaTeX again to get references right, {5} pages
   as usual.

[Reason]
a. `TeX-sentinel-default-function' is declared as an "always buffer-local
   variable" in tex-buf.el:
(make-variable-buffer-local 'TeX-sentinel-default-function)
b. However, latex.el and tex-info.el don't have "(require 'tex-buf)".
   Hence they don't load tex-buf.el until the typesetting. It's only
   after that the user type C-c C-c, C-c C-r etc. that latex.el and
   tex-info.el recognize `TeX-sentinel-default-function' is an "always
   buffer-local variable".
c. Therefore, the forms
  (setq TeX-sentinel-default-function #'TeX-LaTeX-sentinel)
   in `TeX-latex-mode' (latex.el) and
  (setq TeX-sentinel-default-function #'TeX-TeX-sentinel)
   in `TeX-texinfo-mode' (tex-info.el) set its global value, overwriting
   by each other at the procedure 1. and 2. above.

[What to do]
If we are to just "fix" this issue, there are two options:
(A) Replace `setq' for `TeX-sentinel-default-function' with `setq-local'
    in all AUCTeX major modes.
(B) Move `defvar' as well as `make-variable-buffer-local' declaration of
    `TeX-sentinel-default-function' to tex.el from tex-buf.el, in a
    way which Arash reported and treated for a somewhat similar issue
    last June[1].

However, I think that we should first discuss what to do with this
policy spelled out in tex.el:
;; The following dependencies are not done with autoload cookies since
;; they are only useful when tex.el is loaded, anyway.  tex-buf.el
;; should remain unloaded as long as one is only editing files, so
;; requiring it here would be wrong.
(Arash mentioned this, too[1].)

I think that this "separate dependency policy" must be the reason why
latex.el and tex-info.el don't have "(require 'tex-buf)". However, it
seems this policy was eroded significantly in the past development
history of AUCTeX, seeing the following facts:
(1) All of plain-tex.el, context.el, preview.el, tex-bar.el and
    tex-jp.el have "(require 'tex-buf)".
(2) tex.el has "Viewing" section, which isn't necessary as long as
    one is only editing files.
In addition, ELPA installation activates preview-latex unconditionally
for any LaTeX documents, which means that most AUCTeX installations load
tex-buf.el anyway.

So I think that now we should clarify whether AUCTeX should keep or
abandon this policy.

If AUCTeX is to abandon it, the simplest solution to the original
problem of this message is:
(C) Add "(require 'tex-buf)" to latex.el and tex-info.el. (We can omit
    some defvar's and declare-function's in them as well.)

If AUCTeX is to keep it,
(D) We should remove "(require 'tex-buf)" from at least plain-tex.el,
    context.el, tex-bar.el and tex-jp.el, adding some defvar's and
    declare-function's (or autoload's if necessary).
(E; optional?) It's reasonable that preview.el has "(require 'tex-buf)"
    considering its nature; but maybe we should consider replacing it
    with suitable autoload's (adding some defvar's).
(F; optional?) Move entire "Viewing" section from tex.el to tex-buf.el.

My preference is to keep the "separate dependency policy" and do (D) and
(E). Doing (F) is too drastic a change and the commit history of
"Viewing" section is valuable, which doesn't seem good to lose.

What do you think about it?

All the best,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

[1] Thread beginning with
https://lists.gnu.org/r/auctex-devel/2021-06/msg00008.html



reply via email to

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