GNU bug report logs -
#54133
29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers
Previous Next
Reported by: Bob Rogers <rogers <at> rgrjr.com>
Date: Wed, 23 Feb 2022 21:38:01 UTC
Severity: normal
Found in version 29.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54133 in the body.
You can then email your comments to 54133 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Wed, 23 Feb 2022 21:38:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Bob Rogers <rogers <at> rgrjr.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 23 Feb 2022 21:38:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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/
[0001-Make-Buffer-menu-visit-tags-table-more-circumspect.patch (text/x-patch, inline)]
From 05d2d1855cddc8d5c310d718c07d91ae861b8436 Mon Sep 17 00:00:00 2001
From: Bob Rogers <rogers <at> 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.
---
lisp/buff-menu.el | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Thu, 24 Feb 2022 09:20:04 GMT)
Full text and
rfc822 format available.
Message #8 received at 54133 <at> debbugs.gnu.org (full text, mbox):
> 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. ;-}
IIUC the problem is that ‘tags-verify-table' calls 'tags-table-mode'
first and 'verify-tags-table-function' afterwards.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Thu, 24 Feb 2022 15:16:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 54133 <at> debbugs.gnu.org (full text, mbox):
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Wed, 23 Feb 2022 16:37:11 -0500
>
> 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. ;-}
Does the alternative patch below give good results?
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 50c2c15..179cc54 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -527,13 +527,18 @@ Buffer-menu-multi-occur
(multi-occur (Buffer-menu-marked-buffers) regexp nlines))
+(autoload 'etags-verify-tags-table "etags")
(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* ((buf (Buffer-menu-buffer t))
+ (file (buffer-file-name buf)))
+ (cond
+ ((not file) (error "Specified buffer has no file"))
+ ((and buf (with-current-buffer buf
+ (etags-verify-tags-table)))
+ (visit-tags-table file))
+ (t (error "Specified buffer is not a tags-table")))))
(defun Buffer-menu-1-window ()
"Select this line's buffer, alone, in full frame."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Thu, 24 Feb 2022 17:32:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 54133 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org>
Date: Thu, 24 Feb 2022 17:15:54 +0200
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Wed, 23 Feb 2022 16:37:11 -0500
>
> . . .
>
> 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. ;-}
Does the alternative patch below give good results?
This does ineed work, and I had considered something similar, but was
concerned that it would not be as robust. etags-verify-tags-table is
called from etags-recognize-tags-table, which is only a part of the
tags-table-format-functions extension mechanism used by
initialize-new-tags-table. So to avoid breaking this mechanism I would
either have had to call initialize-new-tags-table and have it possibly
set unwanted local variables, or delve more deeply into the internals by
running tags-table-format-functions myself.
In short, I thought checking the major mode was the better choice,
since the file was already present in a buffer.
-- Bob
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Thu, 24 Feb 2022 17:43:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 54133 <at> debbugs.gnu.org (full text, mbox):
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Thu, 24 Feb 2022 12:30:53 -0500
> Cc: 54133 <at> debbugs.gnu.org
>
> From: Eli Zaretskii <eliz <at> gnu.org>
> Date: Thu, 24 Feb 2022 17:15:54 +0200
>
> > From: Bob Rogers <rogers <at> rgrjr.com>
> > Date: Wed, 23 Feb 2022 16:37:11 -0500
> >
> > . . .
> >
> > 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. ;-}
>
> Does the alternative patch below give good results?
>
> This does ineed work, and I had considered something similar, but was
> concerned that it would not be as robust. etags-verify-tags-table is
> called from etags-recognize-tags-table, which is only a part of the
> tags-table-format-functions extension mechanism used by
> initialize-new-tags-table. So to avoid breaking this mechanism I would
> either have had to call initialize-new-tags-table and have it possibly
> set unwanted local variables, or delve more deeply into the internals by
> running tags-table-format-functions myself.
Maybe we should have a more thorough implementation in
etags-verify-tags-table, then. But that function's purpose is to do
what we need here.
> In short, I thought checking the major mode was the better choice,
> since the file was already present in a buffer.
But what if the file is already in a buffer, but not under the right
major-mode? E.g., what if the file was visited literally?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54133
; Package
emacs
.
(Thu, 24 Feb 2022 18:03:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 54133 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org>
Date: Thu, 24 Feb 2022 19:42:14 +0200
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Thu, 24 Feb 2022 12:30:53 -0500
>
> . . .
>
> This does ineed work, and I had considered something similar, but
> was concerned that it would not be as robust . . .
Maybe we should have a more thorough implementation in
etags-verify-tags-table, then. But that function's purpose is to do
what we need here.
That would require disentangling detection and initialization. Which
shouldn't be all that hard; it just seemed like more work than necessary
to scratch this particular itch.
> In short, I thought checking the major mode was the better choice,
> since the file was already present in a buffer.
But what if the file is already in a buffer, but not under the right
major-mode? E.g., what if the file was visited literally?
Ah, so you mean that Buffer-menu-visit-tags-table is normally meant to
introduce tags-table-mode in buffers not already there. I see now that
is implied by "Visit the tags table ..." in the command documentation.
In which case I withdraw my reservations.
And maybe I'll have a look at cleaning up etags initialization when I
get a chance . . .
-- Bob
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Thu, 24 Feb 2022 20:01:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Bob Rogers <rogers <at> rgrjr.com>
:
bug acknowledged by developer.
(Thu, 24 Feb 2022 20:01:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 54133-done <at> debbugs.gnu.org (full text, mbox):
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Thu, 24 Feb 2022 13:02:40 -0500
> CC: 54133 <at> debbugs.gnu.org
>
> Maybe we should have a more thorough implementation in
> etags-verify-tags-table, then. But that function's purpose is to do
> what we need here.
>
> That would require disentangling detection and initialization. Which
> shouldn't be all that hard; it just seemed like more work than necessary
> to scratch this particular itch.
>
> > In short, I thought checking the major mode was the better choice,
> > since the file was already present in a buffer.
>
> But what if the file is already in a buffer, but not under the right
> major-mode? E.g., what if the file was visited literally?
>
> Ah, so you mean that Buffer-menu-visit-tags-table is normally meant to
> introduce tags-table-mode in buffers not already there. I see now that
> is implied by "Visit the tags table ..." in the command documentation.
> In which case I withdraw my reservations.
Thanks, I installed the changes, and I'm marking this bug done.
> And maybe I'll have a look at cleaning up etags initialization when I
> get a chance . . .
TIA.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 25 Mar 2022 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.