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.
Full log
View this message in rfc822 format
> 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."
This bug report was last modified 3 years and 89 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.