Zamansky 20: Yanking and Auto Revert

Mike Zamansky has another video up in his Using Emacs Series. This time he provides a video demonstration of counsel-yank-pop that I wrote about previously here on Irreal. As always, things seem clearer and easier to understand when you see it actually happen.

The other thing that Zamansky covers is auto-revert-mode. It checks if the file you are looking at in Emacs has changed on disk and reloads it if so. If you’re working with a single machine that doesn’t seem very useful or even to make sense1 but it’s really useful when you work on more than a single computer.

To see how it can really help your workflow, let’s assume you work on two separates machines—one at work, one at home, say. In order to keep files synced, you use something like Dropbox. Then when you save a file at work, it also updates your machine at home. The problem occurs when you already have the file open in Emacs on your home machine. Now the on-disk copy and the in-buffer copies differ and it’s easy to get a conflict. This is the exact situation auto-revert-mode fixes. When Emacs sees the file change on disk, it automatically reloads the buffer so that when you come back to your home machine you’ll be working with an up-to-date copy of the file.

Footnotes:

1

It can even be useful on a single machine if you have an external process that occasionally updates a file you’re examining in Emacs—a system log file, for example.

This entry was posted in General and tagged . Bookmark the permalink.