all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Aaron Zeng" <z@bcc32.com>, Michael Albinus <michael.albinus@gmx.de>
Cc: 71424@debbugs.gnu.org
Subject: bug#71424: 29.3; auto-revert-use-notify buggy interaction with indirect buffers
Date: Sat, 08 Jun 2024 19:27:08 +0300	[thread overview]
Message-ID: <86zfrvbdsz.fsf@gnu.org> (raw)
In-Reply-To: <01d36245-763b-43e8-93f8-679f176fedd0@app.fastmail.com> (z@bcc32.com)

> Date: Sat, 08 Jun 2024 11:30:08 -0400
> From: "Aaron Zeng" <z@bcc32.com>
> Cc: 71424@debbugs.gnu.org
> 
> On Sat, Jun 8, 2024, at 03:03, Eli Zaretskii wrote:
> 
> > To see that at least the basic functionality works in Emacs, I did the
> > following:
> >
> >   emacs -Q
> >   C-x C-f SOME-FILE RET
> >   M-x global-auto-revert-mode RET
> >   M-x clone-indirect-buffer RET
> >
> > Then, outside Emacs, typed from the shell prompt
> >
> >   $ cat OTHER-FILE >> SOME-FILE
> >
> > where OTHER-FILE is some other existing file.  After that, I saw both
> > the base buffer's text and that of its indirect clone change to
> > reflect the appended text.
> 
> Indeed, while the indirect buffer is live, everything works fine.  However, after you kill the indirect buffer, then the buffer no longer gets auto-reverted when you modify SOME-FILE outside Emacs.

Right.  Michael, is the below the correct fix?

diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index a23d536..ab69add 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -378,8 +378,11 @@ auto-revert-debug
 (defun auto-revert-remove-current-buffer (&optional buffer)
   "Remove BUFFER from `auto-revert-buffer-list'.
 BUFFER defaults to `current-buffer'."
-  (setq auto-revert-buffer-list
-        (delq (or buffer (current-buffer)) auto-revert-buffer-list)))
+  (let ((buf (or buffer (current-buffer))))
+    ;; Don't remove the watch if we are killing an indirect buffer.
+    (or (buffer-base-buffer buf)
+        (setq auto-revert-buffer-list
+              (delq buf auto-revert-buffer-list)))))
 
 ;;;###autoload
 (define-minor-mode auto-revert-mode
@@ -639,7 +642,9 @@ auto-revert-set-timer
 
 (defun auto-revert-notify-rm-watch ()
   "Disable file notification for current buffer's associated file."
-  (when-let ((desc auto-revert-notify-watch-descriptor))
+  (when-let ((desc
+              (and (buffer-base-buffer)
+                   auto-revert-notify-watch-descriptor)))
     (setq auto-revert--buffer-by-watch-descriptor
           (assoc-delete-all desc auto-revert--buffer-by-watch-descriptor))
     (ignore-errors





  reply	other threads:[~2024-06-08 16:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08  4:44 bug#71424: 29.3; auto-revert-use-notify buggy interaction with indirect buffers z
2024-06-08  4:46 ` bug#71424: Aaron Zeng
2024-06-08  7:03 ` bug#71424: 29.3; auto-revert-use-notify buggy interaction with indirect buffers Eli Zaretskii
2024-06-08 15:30   ` Aaron Zeng
2024-06-08 16:27     ` Eli Zaretskii [this message]
2024-06-08 16:57       ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 17:44         ` Eli Zaretskii
2024-06-10 11:15           ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 17:06       ` Aaron Zeng
2024-06-08 17:45         ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=86zfrvbdsz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=71424@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=z@bcc32.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.