GNU bug report logs - #77335
30.1; RefTeX: Move some 'setq' expressions out of loop

Previous Next

Package: emacs;

Reported by: Pengji Zhang <me <at> pengjiz.com>

Date: Fri, 28 Mar 2025 10:43:02 UTC

Severity: normal

Found in version 30.1

To reply to this bug, email your comments to 77335 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#77335; Package emacs. (Fri, 28 Mar 2025 10:43:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pengji Zhang <me <at> pengjiz.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 28 Mar 2025 10:43:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pengji Zhang <me <at> pengjiz.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; RefTeX: Move some 'setq' expressions out of loop
Date: Fri, 28 Mar 2025 18:42:22 +0800
[Message part 1 (text/plain, inline)]
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!

[0001-Move-some-RefTeX-setq-s-to-major-mode-definition.patch (text/x-patch, inline)]
From 6a73bba1a2954daabe728e007eb55e839993e1d8 Mon Sep 17 00:00:00 2001
From: Pengji Zhang <me <at> pengjiz.com>
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


This bug report was last modified 6 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.