From: Eli Zaretskii <eliz@gnu.org>
To: Bob Rogers <rogers@rgrjr.com>
Cc: 54133@debbugs.gnu.org
Subject: bug#54133: 29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers
Date: Thu, 24 Feb 2022 17:15:54 +0200 [thread overview]
Message-ID: <8335k8s3bp.fsf@gnu.org> (raw)
In-Reply-To: <25110.43271.146078.920965@orion.rgrjr.com> (message from Bob Rogers on Wed, 23 Feb 2022 16:37:11 -0500)
> From: Bob Rogers <rogers@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))
\f
+(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."
next prev parent reply other threads:[~2022-02-24 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 21:37 bug#54133: 29.0.50; Buffer-menu-visit-tags-table disrupts non-tags buffers Bob Rogers
2022-02-24 9:19 ` martin rudalics
2022-02-24 15:15 ` Eli Zaretskii [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8335k8s3bp.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=54133@debbugs.gnu.org \
--cc=rogers@rgrjr.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).