bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71727: Deleting TAGS buffer will cause `etags-regen--update-file` do


From: Dmitry Gutov
Subject: bug#71727: Deleting TAGS buffer will cause `etags-regen--update-file` doesn't work
Date: Thu, 11 Jul 2024 03:50:15 +0300
User-agent: Mozilla Thunderbird

Now pushed to emacs-30, please report any further problems.

On 09/07/2024 05:50, Dmitry Gutov wrote:
On 29/06/2024 14:49, Siyuan Chen wrote:
 > Is there are particular reason you killed the TAGS buffer?

No. I found this bug is just because I tried to view the TAGS content while editing a .c file and then closed it (I am using tab-line-mode with tab-line-close-tab-function set to kill-buffer). Since then, I have stopped closing the TAGS buffer.

Thanks for the clarification.

Another option is to temporarily add documentation advising users not to close the TAGS buffer, because closing it accidentally can result in the odd behavior.

I think actually a simpler approach can suffice: using kill-buffer-hook in the TAGS buffer. Like this:

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 @@ etags-regen--visit-table
    (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 @@ etags-regen--mark-as-new

  (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)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]