From: Bob Rogers <rogers@rgrjr.com>
To: 54133@debbugs.gnu.org
Subject: bug#54133: 29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers
Date: Wed, 23 Feb 2022 16:37:11 -0500 [thread overview]
Message-ID: <25110.43271.146078.920965@orion.rgrjr.com> (raw)
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 1918 bytes --]
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
of 2022-02-19 built on orion
Repository revision: 563bb08c5998f82e034a0aa1b48dce29fb9bc375
Repository branch: rgr-smtpmail-env-from
Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
System Description: openSUSE Leap 15.3
Configured using:
'configure --with-dbus=no --with-gsettings=no --with-gif=ifavailable
--with-tiff=no --with-gnutls=yes --with-gconf=no'
Configured features:
ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2
MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB
To reproduce:
In master ecaedf2117cb015ad4028e4d6fc7058608c98096:
1. "emacs -Q &"
2. Visit pretty much any random file that is NOT a tags file; for
this purpose, lisp/abbrev.el from the source tree will do nicely.
3. Type "C-x C-b" to get the "*Buffer List*" window to appear.
4. Type "C-x o" to move the to the buffer list, then move to the
abbrev.el line, and type "t" to invoke Buffer-menu-visit-tags-table on
it (which I seem to do accidentally more often than I care to admit).
This produces the error message:
user-error: File /scratch/rogers/emacs/lisp/abbrev.el is not a valid tags table
but the abbrev.el buffer is left in tags-table-mode, and any undo
information is thrown away.
The attached patch addresses the problem in a straightforward way by
making Buffer-menu-visit-tags-table prompt the user for buffers not
already in tags-table-mode.
The real problem is that visit-tags-table assumes that the user knows
what they're doing, and makes these irreversible changes before being
sure of having a valid tags table. That would be a harder thing to fix,
though -- and might not deal as well with my buffer-menu typos. ;-}
-- Bob Rogers
http://www.rgrjr.com/
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1780 bytes --]
From 05d2d1855cddc8d5c310d718c07d91ae861b8436 Mon Sep 17 00:00:00 2001
From: Bob Rogers <rogers@rgrjr.com>
Date: Wed, 23 Feb 2022 16:23:17 -0500
Subject: [PATCH] Make Buffer-menu-visit-tags-table more circumspect
* lisp/buff-menu.el:
+ (Buffer-menu-visit-tags-table): Ask before visit-tags-table on a
buffer not already in tags-table-mode, lest it destroy state.
---
| 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
--git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 50c2c155ca..0bed539008 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -530,10 +530,21 @@ Buffer-menu-multi-occur
(defun Buffer-menu-visit-tags-table ()
"Visit the tags table in the buffer on this line. See `visit-tags-table'."
(interactive nil Buffer-menu-mode)
- (let ((file (buffer-file-name (Buffer-menu-buffer t))))
- (if file
- (visit-tags-table file)
- (error "Specified buffer has no file"))))
+ (let* ((buffer (Buffer-menu-buffer t))
+ (file (buffer-file-name buffer)))
+ (or file
+ (error "Specified buffer has no file"))
+ ;; Ensure that it's really a tags file buffer (or the user at
+ ;; least believes it should be). Otherwise, visit-tags-table will
+ ;; change the mode and discard any undo information.
+ (if (not (or (eq (with-current-buffer buffer
+ major-mode)
+ 'tags-table-mode)
+ (yes-or-no-p
+ (format "%s is not a tags table; visit as such anyway? "
+ buffer))))
+ (error "Aborted."))
+ (visit-tags-table file)))
(defun Buffer-menu-1-window ()
"Select this line's buffer, alone, in full frame."
--
2.34.1
next reply other threads:[~2022-02-23 21:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 21:37 Bob Rogers [this message]
2022-02-24 9:19 ` bug#54133: 29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers martin rudalics
2022-02-24 15:15 ` Eli Zaretskii
2022-02-24 17:30 ` Bob Rogers
2022-02-24 17:42 ` Eli Zaretskii
2022-02-24 18:02 ` Bob Rogers
2022-02-24 20:00 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25110.43271.146078.920965@orion.rgrjr.com \
--to=rogers@rgrjr.com \
--cc=54133@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.