From: Dmitry Gutov Date: Thu, 11 Jul 2024 00:49:06 +0000 (+0300) Subject: etags-regen-mode: Handle TAGS buffer being killed X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2b9ac4b917e2db71f0d9d24f6f60bd8975f5e630;p=emacs.git 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. (cherry picked from commit 9331ab056a426b334d46c38659c9de2053eb45f3) --- diff --git a/lisp/progmodes/etags-regen.el b/lisp/progmodes/etags-regen.el index dc778b14061..21ea9bfb8b3 100644 --- a/lisp/progmodes/etags-regen.el +++ b/lisp/progmodes/etags-regen.el @@ -294,7 +294,9 @@ File extensions to generate the tags for." (add-hook 'before-save-hook #'etags-regen--mark-as-new) (setq etags-regen--tags-file tags-file 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 () (string-search "Ctags" @@ -390,7 +392,8 @@ File extensions to generate the tags for." (defun etags-regen--tags-cleanup () (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 (kill-buffer buffer))) (tags-reset-tags-tables)