unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Siyuan Chen <chansey97@gmail.com>
Cc: 71727@debbugs.gnu.org
Subject: bug#71727: Deleting TAGS buffer will cause `etags-regen--update-file` doesn't work
Date: Tue, 9 Jul 2024 05:50:12 +0300	[thread overview]
Message-ID: <a89ea29c-9d70-41d9-942f-9d3eb3b68f05@gutov.dev> (raw)
In-Reply-To: <CAHWTsY=qFgSa00ZpkU+9LqswNSqvSOUGsN4koSZuvt98BJWpDA@mail.gmail.com>

Hi again!

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	other threads:[~2024-07-09  2:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-22 23:55 bug#71727: Deleting TAGS buffer will cause `etags-regen--update-file` doesn't work Siyuan Chen
2024-06-27  8:49 ` Eli Zaretskii
2024-06-28  1:23 ` Dmitry Gutov
2024-06-29 11:49   ` Siyuan Chen
2024-07-09  2:50     ` Dmitry Gutov [this message]
2024-07-11  0:50       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a89ea29c-9d70-41d9-942f-9d3eb3b68f05@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=71727@debbugs.gnu.org \
    --cc=chansey97@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).