branch: main
commit 0718ac55e8d3beece26a3448f968e14c53e7910c
Author: Arash Esbati <ar...@gnu.org>
Commit: Arash Esbati <ar...@gnu.org>

    Remove stale verbatim entries from auto-parsed files
    
    * NEWS.org (Fixed): Announce the fix.
    
    * latex.el (LaTeX-verbatim-macros-with-delims-local)
    (LaTeX-verbatim-macros-with-braces-local)
    (LaTeX-verbatim-environments-local): Add variables to
    `TeX-normal-mode-reset-list'.  Resetting them removes stale
    entries in auto-parsed files when styles adding entries to them
    are removed in the original .tex file.  (bug#70807)
---
 NEWS.org |  3 +++
 latex.el | 23 ++++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 40bfa752..e0bfa8b5 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -19,6 +19,9 @@
   enabled.
 - Fix the command-line options passed to latexmk when processing files
   with xetex in order to run the viewer correctly.
+- Fix removing of stale verbatim entries in auto-parsed file once the
+  corresponding package isn't used in the .tex file anymore.  Complete
+  removal may require two invocations of =C-u C-c C-n=.
 
 * [14.0.9] - 2025-02-25
 
diff --git a/latex.el b/latex.el
index 79d79303..d27a2169 100644
--- a/latex.el
+++ b/latex.el
@@ -3883,10 +3883,15 @@ Style files should add constructs to this variable and 
not to
 Programs should not use this variable directly but the function
 `LaTeX-verbatim-macros-with-delims' which returns a value
 including values of the variable
-`LaTeX-verbatim-macros-with-delims' as well.")
+`LaTeX-verbatim-macros-with-delims' as well.
+
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 (put 'LaTeX-verbatim-macros-with-delims-local 'safe-local-variable
      #'TeX--list-of-string-p)
 
+;; Add the variable to `TeX-normal-mode-reset-list':
+(add-to-list 'TeX-normal-mode-reset-list
+             'LaTeX-verbatim-macros-with-delims-local)
 
 (defcustom LaTeX-verbatim-macros-with-braces nil
   "Macros for inline verbatim with arguments in braces, like \\foo{...}.
@@ -3907,10 +3912,16 @@ Style files should add constructs to this variable and 
not to
 Programs should not use this variable directly but the function
 `LaTeX-verbatim-macros-with-braces' which returns a value
 including values of the variable
-`LaTeX-verbatim-macros-with-braces' as well.")
+`LaTeX-verbatim-macros-with-braces' as well.
+
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 (put 'LaTeX-verbatim-macros-with-braces-local 'safe-local-variable
      #'TeX--list-of-string-p)
 
+;; Add the variable to `TeX-normal-mode-reset-list':
+(add-to-list 'TeX-normal-mode-reset-list
+             'LaTeX-verbatim-macros-with-braces-local)
+
 (defcustom LaTeX-verbatim-environments
   '("verbatim" "verbatim*" "filecontents" "filecontents*")
   "Verbatim environments.
@@ -3930,10 +3941,16 @@ Style files should add constructs to this variable and 
not to
 
 Programs should not use this variable directly but the function
 `LaTeX-verbatim-environments' which returns a value including
-values of the variable `LaTeX-verbatim-environments' as well.")
+values of the variable `LaTeX-verbatim-environments' as well.
+
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 (put 'LaTeX-verbatim-environments-local 'safe-local-variable
      #'TeX--list-of-string-p)
 
+;; Add the variable to `TeX-normal-mode-reset-list':
+(add-to-list 'TeX-normal-mode-reset-list
+             'LaTeX-verbatim-environments-local)
+
 (defun LaTeX-verbatim-macros-with-delims ()
   "Return list of verbatim macros with delimiters."
   (append LaTeX-verbatim-macros-with-delims

Reply via email to