Make 't' in bs-mode be more defensive

* lisp/bs.el (bs-visit-tags-table): Verify that	the
buffer holds a tags-table file before using it as
such. This is identical to bug#54133 affecting
Buffer-menu, and this fix is copied from the one
by Eli Zaretskii in commit 794fbd1c07 of 2022-02-24.
Thanks to Bob Rogers <rogers@rgrjr.com> for noticing.
This commit is contained in:
Juanma Barranquero 2022-11-10 01:31:22 +01:00
parent 78144156b0
commit ef3627508a

View file

@ -823,10 +823,14 @@ Leave Buffer Selection Menu."
"Visit the tags table in the buffer on this line.
See `visit-tags-table'."
(interactive)
(let ((file (buffer-file-name (bs--current-buffer))))
(if file
(visit-tags-table file)
(error "Specified buffer has no file"))))
(let* ((buf (bs--current-buffer))
(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 bs-toggle-current-to-show ()
"Toggle status of showing flag for buffer in current line."