[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
autorevert vs git checkout
From: |
Herman, Geza |
Subject: |
autorevert vs git checkout |
Date: |
Fri, 1 Jan 2021 14:01:48 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
Hi all,
It seems that immediate autorevert (I mean autorevert induced by OS file
watcher) doesn't work on git checkout. As git first deletes the file,
and then puts a new version during checkout, emacs only autoreverts
these files periodically (auto-revert-interval), not immediately.
Even magit's magit-auto-revert-immediately doesn't work correctly
because of this.
Currently I'm using these advices on magit functions to handle the
situation better, but I wonder is there a better solution?
(defun my-refresh-buffers (&rest r)
(dolist (b (buffer-list))
(with-current-buffer b
(when buffer-file-name
(unless (buffer-modified-p) (revert-buffer :ignore-auto
:noconfirm)))))
)
(advice-add 'magit-checkout :after 'my-refresh-buffers)
(advice-add 'magit-branch-checkout :after 'my-refresh-buffers)
(advice-add 'magit-branch-orphan :after 'my-refresh-buffers)
(advice-add 'magit-branch-and-checkout :after 'my-refresh-buffers)
(advice-add 'magit-branch-or-checkout :after 'my-refresh-buffers)
(advice-add 'magit-branch-spinoff :after 'my-refresh-buffers)
Thanks,
Geza
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- autorevert vs git checkout,
Herman, Geza <=