Subject: 30.1; RefTeX: Move some 'setq' expressions out of loop
From: Pengji Zhang <[email-masked]>
To: [email-masked]
Date: Fri, 28 Mar 2025 18:42:22 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

(I am not sure if this is the right list to submit a patch for RefTeX.
Please let me know if it is not. Thanks!)

In the function 'reftex-offer-label-menu', there are two 'setq'
expressions inside a loop. That makes it hard for users to change those
settings. For example, I would like to remove 'global-mode-string' from
the mode line of the label buffer, but there is no easy way to do so.

This patch moves the two 'setq' expressions to the definition of the
major mode for the buffer, so users could use the mode hook to tweak
those two settings.

Thanks!

From 6a73bba1a2954daabe728e007eb55e839993e1d8 Mon Sep 17 00:00:00 2001
From: Pengji Zhang <[email-masked]>
Date: Sun, 23 Mar 2025 11:48:14 +0800
Subject: [PATCH] Move some RefTeX 'setq's to major mode definition

Move two 'setq' expressions from the RefTeX label selection loop
to the body of the major mode definition, so to make it easier
to adjust the settings of the buffer via the mode hook.

* lisp/textmodes/reftex-ref.el (reftex-offer-label-menu): Move
two 'setq' expressions from here...
* lisp/textmodes/reftex-sel.el (reftex-select-label-mode): ...to
here.
---
 lisp/textmodes/reftex-ref.el | 6 ------
 lisp/textmodes/reftex-sel.el | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 30e9968a8e5..cac5ad65e86 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -569,12 +569,6 @@ reftex-offer-label-menu
               (unless (eq major-mode 'reftex-select-label-mode)
                 (reftex-select-label-mode))
               (cl-pushnew (current-buffer) selection-buffers)
-              (setq truncate-lines t)
-              (setq mode-line-format
-                    (list "----  " 'mode-line-buffer-identification
-                          "  " 'global-mode-string "   (" mode-name ")"
-                          "  S<" 'reftex-refstyle ">"
-                          " -%-"))
               (cond
                ((= 0 (buffer-size))
                 (let ((buffer-read-only nil))
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index 1f1c74550a5..4fbbb1fdeb0 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -98,6 +98,12 @@ reftex-select-label-mode
 
 \\{reftex-select-label-mode-map}"
   (setq-local reftex-select-marked nil)
+  (setq truncate-lines t)
+  (setq mode-line-format
+        (list "----  " 'mode-line-buffer-identification
+              "  " 'global-mode-string "   (" mode-name ")"
+              "  S<" 'reftex-refstyle ">"
+              " -%-"))
   (when (syntax-table-p reftex-latex-syntax-table)
     (set-syntax-table reftex-latex-syntax-table))
   ;; We do not set a local map - reftex-select-item does this.
-- 
2.49.0