In one of my windows I've opened "output.png" and I would like emacs to automatically reload it if it has changed.
I would like to do this for all PNG files which are currently open, but only PNG files. How to I do this?
In one of my windows I've opened "output.png" and I would like emacs to automatically reload it if it has changed.
I would like to do this for all PNG files which are currently open, but only PNG files. How to I do this?
You need to enable the auto-revert-mode
. It will reload the file every 5 seconds. see gnu.org/emacs/manual/Reverting
To enable it in the image buffer for the current session only type M-x auto-revert-mode
Note: in my experience with Emacs 25.3 the buffer will display the image as ascii text after reverting it. To fix that type: M-x auto-image-file-mode
To use these settings for all buffers displaying an image I've added to my ~/.emacs/
file:
(add-hook 'image-mode-hook
(lambda ()
(auto-revert-mode)
(auto-image-file-mode)))
auto-revert-use-notify
was introduced in 24.4, but then disabled by global-auto-revert-mode
in 25.1 due to bug#22814 (which seems like it was specific to OSX, but I haven't read it in detail), and was re-enabled again in 26.1, with a solution for that bug having been committed.
– phils
Sep 13 '18 at 07:35
auto-image-file-mode
is a global minor mode, so just use (auto-image-file-mode 1)
in your init file, rather than calling it every time image-mode-hook
runs.
– phils
Sep 13 '18 at 07:39
(add-hook 'image-mode-hook 'auto-revert-mode)
– phils
Sep 13 '18 at 07:39