all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 34847@debbugs.gnu.org, Dale Sedivec <dale@codefu.org>
Subject: bug#34847: 27.0.50; auto-revert-buffers occasionally selects a killed buffer
Date: Sat, 06 Apr 2019 03:02:45 +0100	[thread overview]
Message-ID: <87a7h3lwl6.fsf@tcd.ie> (raw)
In-Reply-To: <87tvfsgx8y.fsf@gmx.de> (Michael Albinus's message of "Sun, 24 Mar 2019 15:31:09 +0100")

[-- Attachment #1: Type: text/plain, Size: 2684 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

> Something like this. But the final `auto-revert-remove-current-buffer'
> needs the buffer to be removed as the current one. So it is a bit more
> complex.
>
> I came up with the following patch:
>
> *** /tmp/ediffWnT0dx	2019-03-24 15:30:02.022068542 +0100
> --- /home/albinus/src/emacs/lisp/autorevert.el	2019-03-24 15:26:41.756960378 +0100
> ***************
> *** 343,352 ****
>
>   ;; Functions:
>
> ! (defun auto-revert-remove-current-buffer ()
>     "Remove dead buffer from `auto-revert-buffer-list'."
>     (setq auto-revert-buffer-list
> !         (delq (current-buffer) auto-revert-buffer-list)))
>
>   ;;;###autoload
>   (define-minor-mode auto-revert-mode
> --- 343,352 ----
>
>   ;; Functions:
>
> ! (defun auto-revert-remove-current-buffer (&optional buffer)
>     "Remove dead buffer from `auto-revert-buffer-list'."
>     (setq auto-revert-buffer-list
> !         (delq (or buffer (current-buffer)) auto-revert-buffer-list)))
>
>   ;;;###autoload
>   (define-minor-mode auto-revert-mode

Can you please update the docstring?  E.g.

  "Remove BUFFER from `auto-revert-buffer-list'.
BUFFER defaults to `current-buffer'."

> ***************
> *** 772,781 ****
>         (setq bufs (delq nil
>                          (mapcar
>                           (lambda (buf)
> !                           (with-current-buffer buf
> !                             (and (or (not (file-remote-p default-directory))
> !                                      (file-remote-p default-directory nil t))
> !                                  buf)))
>                           bufs)))
>         ;; Partition `bufs' into two halves depending on whether or not
>         ;; the buffers are in `auto-revert-remaining-buffers'.  The two
> --- 772,783 ----
>         (setq bufs (delq nil
>                          (mapcar
>                           (lambda (buf)
> !                           (and (buffer-live-p buf)
> !                                (with-current-buffer buf
> !                                  (and
> !                                   (or (not (file-remote-p default-directory))
> !                                       (file-remote-p default-directory nil t))
> !                                       buf))))
>                           bufs)))
>         ;; Partition `bufs' into two halves depending on whether or not
>         ;; the buffers are in `auto-revert-remaining-buffers'.  The
>   two

Indentation seems a bit off here.  Note that you can use 'when' instead
of 'and' to fit more easily within 80 columns, if you prefer.

Otherwise LGTM.  Can you please also make the following change while
you're at it?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: autorevert.diff --]
[-- Type: text/x-diff, Size: 557 bytes --]

diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index bc7c616ecb..d736f0d31c 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -509,7 +509,7 @@ auto-revert-notify-rm-watch
 	   (ignore-errors
 	     (file-notify-rm-watch auto-revert-notify-watch-descriptor)))))
      auto-revert-notify-watch-descriptor-hash-list)
-    (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch))
+    (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t))
   (setq auto-revert-notify-watch-descriptor nil
 	auto-revert-notify-modified-p nil))
 

[-- Attachment #3: Type: text/plain, Size: 498 bytes --]


It seems to have been left over from a past change:

* lisp/autorevert.el: Use lexical-binding.  Fix hook usage.
  2015-05-22 00:03:12 -0400
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9e41e0bc6a6fdb7a01841db62d8de42d67be534a

> Could you pls check whether the patch works for you with magit? (I
> don't use magit myself)

Works for me; I hope to see it land soon.  See also my other message for
a related but more subtle problem: https://debbugs.gnu.org/34847#16

Thanks,

-- 
Basil

  parent reply	other threads:[~2019-04-06  2:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 18:03 bug#34847: 27.0.50; auto-revert-buffers occasionally selects a killed buffer Dale Sedivec
2019-03-24 14:31 ` Michael Albinus
2019-04-05 14:03   ` Tassilo Horn
2019-04-06  9:07     ` Michael Albinus
2019-04-06  2:02   ` Basil L. Contovounesios [this message]
2019-04-06  9:37     ` Michael Albinus
2019-04-06 13:42       ` Basil L. Contovounesios
2019-04-06  1:55 ` Basil L. Contovounesios
2019-04-06  6:39   ` Eli Zaretskii
2019-04-06 13:39     ` Basil L. Contovounesios

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=87a7h3lwl6.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=34847@debbugs.gnu.org \
    --cc=dale@codefu.org \
    --cc=michael.albinus@gmx.de \
    /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.