auctex-devel
[Top][All Lists]
Advanced

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

TeX-remove-style-hook is local


From: Stefan Monnier
Subject: TeX-remove-style-hook is local
Date: Tue, 26 May 2020 07:16:39 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

I'd like to install the patch below but would like some confirmation
that my understanding is right.

AFAICT, `TeX-auto-add-type` is a macro that's run exclusively at the
top-level of some of AUCTeX's files (context.el, tex.el, and latex.el),
and it uses `add-hook` without a "local" argument in order to add
a function to `TeX-remove-style-hook`, but that variable is declared
buffer-local which makes `add-hook` operate on the buffer-local part of
the hook rather than on the local part.

My understanding is that the intention is to add the function on the
global part of the hook, which is what the patch below does.
If the intention is to add it buffer-locally, then the code will need to
be restructured since the `add-hook` currently runs only when loading
AUCTeX and not when enabling the mode.


        Stefan


diff --git a/tex.el b/tex.el
index e8b9e72c5..e89bb25e8 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2019 Free Software Foundation, Inc.
+;; Copyright (C) 1985-2020 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -2998,7 +2998,6 @@ FORCE is not nil."
 
 (defvar TeX-remove-style-hook nil
   "List of hooks to call when we remove the style specific information.")
- (make-variable-buffer-local 'TeX-remove-style-hook)
 
 (defun TeX-remove-style ()
   "Remove all style specific information."
@@ -3855,6 +3854,7 @@ Generated by `TeX-auto-add-type'.")
        ;; Append new type to `TeX-auto-parser' in order to make `style' type
        ;; always the first.
        (add-to-list 'TeX-auto-parser ',(list name tmp add local change) t)
+       ;; FIXME: This used to modify only the buffer-local part of the hook!
        (add-hook 'TeX-remove-style-hook
                 (lambda ()
                   (setq ,local nil))))))




reply via email to

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