Subject: Re: bug#69254: 14.0.2; outline-hide-body doesn't work when called in LaTeX-mode-hook

From: Ikumi Keita <[email-masked]>
Date: Fri, 23 Feb 2024 15:23:13 +0900

Hi Arash,

>>>>> Arash Esbati <[email-masked]> writes:
> I think that "customized section commands defined in file local
> variables" is more a corner case than enabling `outline-minor-mode' via
> `LaTeX-mode-hook'; and we a have recipe for former if needed.  So it's
> up to us to make a decision here: there will be unhappy customers, but
> how many?  ;-)

I see, here is a tentative patch. Do you think that we should also
revert the similar changes for paragraph related variables?

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW

diff --git a/context.el b/context.el
index 5ee0217d..86991ccf 100644
--- a/context.el
+++ b/context.el
@@ -1875,9 +1875,8 @@ that is, you do _not_ have to cater for this yourself by adding \\\\\\=' or $."
   ;; Outline support
   (require 'outline)
   (set (make-local-variable 'outline-level) #'ConTeXt-outline-level)
-  ;; Moved after `run-mode-hooks'. (bug#65750)
-  ;; (set (make-local-variable 'outline-regexp) (ConTeXt-outline-regexp t))
-  ;;(make-local-variable 'outline-heading-end-regexp)
+  (set (make-local-variable 'outline-regexp) (ConTeXt-outline-regexp t))
+  (make-local-variable 'outline-heading-end-regexp)
   (setq TeX-header-end (ConTeXt-header-end)
         TeX-trailer-start (ConTeXt-trailer-start))
 
@@ -1913,10 +1912,7 @@ Run after mode hooks and file local variables application."
          "[ \t]*\\("
          (ConTeXt-paragraph-commands-regexp) "\\|"
          "\\$\\$\\|" ; Plain TeX display math
-         "$\\)"))
-
-  (or (local-variable-p 'outline-regexp)
-      (setq-local outline-regexp (ConTeXt-outline-regexp t))))
+         "$\\)")))
 
 (defun context-guess-current-interface ()
   "Guess what ConTeXt interface the current buffer is using."
diff --git a/latex.el b/latex.el
index 83de0e84..de70c7f5 100644
--- a/latex.el
+++ b/latex.el
@@ -8268,16 +8268,6 @@ Run after mode hooks and file local variables application."
   (if (bound-and-true-p filladapt-mode)
       (turn-off-filladapt-mode))
 
-  ;; Don't overwrite the value the user set by hooks or file
-  ;; (directory) local variables.
-  (or (local-variable-p 'outline-regexp)
-      (setq-local outline-regexp (LaTeX-outline-regexp t)))
-  (or (local-variable-p 'outline-heading-alist)
-      (setq outline-heading-alist
-            (mapcar (lambda (x)
-                      (cons (concat "\\" (nth 0 x)) (nth 1 x)))
-                    LaTeX-section-list)))
-
   ;; Keep `LaTeX-paragraph-commands-regexp' in sync with
   ;; `LaTeX-paragraph-commands' in case the latter is updated by
   ;; hooks or file (directory) local variables.
@@ -8441,13 +8431,12 @@ function would return non-nil and `(match-string 1)' would return
 
   (require 'outline)
   (set (make-local-variable 'outline-level) #'LaTeX-outline-level)
-  ;; Moved after `run-mode-hooks'. (bug#65750)
-  ;; (set (make-local-variable 'outline-regexp) (LaTeX-outline-regexp t))
-  ;; (when (boundp 'outline-heading-alist)
-  ;;   (setq outline-heading-alist
-  ;;         (mapcar (lambda (x)
-  ;;                   (cons (concat "\\" (nth 0 x)) (nth 1 x)))
-  ;;                 LaTeX-section-list)))
+  (set (make-local-variable 'outline-regexp) (LaTeX-outline-regexp t))
+  (when (boundp 'outline-heading-alist)
+    (setq outline-heading-alist
+          (mapcar (lambda (x)
+                    (cons (concat "\\" (nth 0 x)) (nth 1 x)))
+                  LaTeX-section-list)))
 
   (setq-local TeX-auto-full-regexp-list
               (delete-dups (append LaTeX-auto-regexp-list
diff --git a/tex-info.el b/tex-info.el
index fc10f018..9f919ee3 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -31,9 +31,6 @@
 
 (require 'texinfo)
 
-;; Silence the compiler for variables:
-(defvar outline-heading-alist)
-
 ;;; Environments:
 (defvar Texinfo-environment-list
   '(("cartouche") ("command") ("copying") ("defcv") ("deffn") ("defivar")
@@ -672,13 +669,12 @@ value of `Texinfo-mode-hook'."
   (set (make-local-variable 'syntax-propertize-function)
        texinfo-syntax-propertize-function)
 
-  ;; Moved after `run-mode-hooks'. (bug#65750)
-  ;; (setq-local outline-heading-alist
-  ;;             (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
-  ;;       	      texinfo-section-list))
-  ;; (setq-local outline-regexp
-  ;;             (concat (regexp-opt (mapcar #'car outline-heading-alist) t)
-  ;;       	      "\\>"))
+  (setq-local outline-heading-alist
+              (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
+        	      texinfo-section-list))
+  (setq-local outline-regexp
+              (concat (regexp-opt (mapcar #'car outline-heading-alist) t)
+        	      "\\>"))
 
   ;; Mostly AUCTeX stuff
   (set (make-local-variable 'TeX-command-current) #'TeX-command-master)
@@ -873,16 +869,6 @@ Run after mode hooks and file local variables application."
                    texinfo-chapter-level-regexp
                    "\\)")))
 
-  ;; Outline settings.
-  (or (local-variable-p 'outline-heading-alist)
-      (setq-local outline-heading-alist
-	          (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
-		          texinfo-section-list)))
-  (or (local-variable-p 'outline-regexp)
-      (setq-local outline-regexp
-	          (concat (regexp-opt (mapcar #'car outline-heading-alist) t)
-		          "\\>")))
-
   (or (local-variable-p 'TeX-complete-list)
       (setq-local TeX-complete-list
                   (list (list "@\\([a-zA-Z]*\\)" 1 #'TeX-symbol-list-filtered nil)