etags-regen-mode: Handle TAGS buffer being killed

* lisp/progmodes/etags-regen.el (etags-regen--visit-table):
Use kill-buffer-hook to ensure a refresh if the TAGS buffer is
killed manually (bug#71727).
(etags-regen--tags-cleanup):
Bind the hook var to nil to avoid an infloop.
This commit is contained in:
Dmitry Gutov 2024-07-11 03:49:06 +03:00
parent ef3f26ec02
commit 9331ab056a

View file

@ -294,7 +294,9 @@ File extensions to generate the tags for."
(add-hook 'before-save-hook #'etags-regen--mark-as-new) (add-hook 'before-save-hook #'etags-regen--mark-as-new)
(setq etags-regen--tags-file tags-file (setq etags-regen--tags-file tags-file
etags-regen--tags-root root) etags-regen--tags-root root)
(visit-tags-table etags-regen--tags-file)) (visit-tags-table etags-regen--tags-file)
(with-current-buffer (get-file-buffer tags-file)
(add-hook 'kill-buffer-hook #'etags-regen--tags-cleanup nil t)))
(defun etags-regen--ctags-p () (defun etags-regen--ctags-p ()
(string-search "Ctags" (string-search "Ctags"
@ -390,7 +392,8 @@ File extensions to generate the tags for."
(defun etags-regen--tags-cleanup () (defun etags-regen--tags-cleanup ()
(when etags-regen--tags-file (when etags-regen--tags-file
(let ((buffer (get-file-buffer etags-regen--tags-file))) (let ((buffer (get-file-buffer etags-regen--tags-file))
kill-buffer-hook)
(and buffer (and buffer
(kill-buffer buffer))) (kill-buffer buffer)))
(tags-reset-tags-tables) (tags-reset-tags-tables)