emacs-diffs
[Top][All Lists]
Advanced

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

master 7782ccd: Fix up previous conf-mode/tex-mode redirection hacks


From: Lars Ingebrigtsen
Subject: master 7782ccd: Fix up previous conf-mode/tex-mode redirection hacks
Date: Wed, 25 Aug 2021 05:41:45 -0400 (EDT)

branch: master
commit 7782ccd6de259c14c3843cfed38d944d91b32c89
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix up previous conf-mode/tex-mode redirection hacks
    
    * lisp/textmodes/conf-mode.el (conf-mode):
    * lisp/textmodes/tex-mode.el (tex--redirect-to-submode): The
    previous hack to these redirections would disable all local
    variables.  Try to work around this a bit more.
---
 lisp/textmodes/conf-mode.el | 10 ++++++----
 lisp/textmodes/tex-mode.el  |  6 ++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 949d8cb..57ec8a0 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -417,16 +417,18 @@ See also `conf-space-mode', `conf-colon-mode', 
`conf-javaprop-mode',
 ;; To tell the difference between those two cases where the function
 ;; might be called, we check `delay-mode-hooks'.
 ;; (inspired from tex-mode.el)
+(defvar conf-mode--recursing nil)
 (advice-add 'conf-mode :around
             (lambda (orig-fun)
               "Redirect to one of the submodes when called directly."
               ;; The file may have "mode: conf" in the local variable
               ;; block, in which case we'll be called recursively
               ;; infinitely.  Inhibit that.
-              (let ((enable-local-variables nil))
-                (funcall (if delay-mode-hooks orig-fun (conf--guess-mode))))))
-
-
+              (let ((conf-mode--recursing conf-mode--recursing))
+                (funcall (if (or delay-mode-hooks conf-mode--recursing)
+                             orig-fun
+                           (setq conf-mode--recursing t)
+                           (conf--guess-mode))))))
 
 (defun conf-mode-initialize (comment &optional font-lock)
   "Initializations for sub-modes of `conf-mode'.
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 2a61e4e..d7cd0ac 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1014,15 +1014,17 @@ says which mode to use."
   (tex-common-initialization))
 
 (advice-add 'tex-mode :around #'tex--redirect-to-submode)
+(defvar tex-mode--recursing nil)
 (defun tex--redirect-to-submode (orig-fun)
   "Redirect to one of the submodes when called directly."
   ;; The file may have "mode: tex" in the local variable
   ;; block, in which case we'll be called recursively
   ;; infinitely.  Inhibit that.
-  (let ((enable-local-variables nil))
-    (funcall (if delay-mode-hooks
+  (let ((tex-mode--recursing tex-mode--recursing))
+    (funcall (if (or delay-mode-hooks tex-mode--recursing)
                  ;; We're called from one of the children already.
                  orig-fun
+               (setq tex-mode--recursing t)
                (tex--guess-mode)))))
 
 ;; The following three autoloaded aliases appear to conflict with



reply via email to

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