1

Suppose I open a file in a buffer of Emacs, and then some other program different from Emacs modifies the file. When I try to modify the buffer in Emacs, Emacs will notify me about the change which has occurred to the file outside Emacs. It will give me an option called "revert".

If I understand correctly, "revert" means to reload the file in the file system into the Emacs buffer, so the buffer will be updated with the latest change to the file made outside Emacs.

Literally, "revert" means to undo the last change to something and change the state of something back to its previous state. Then why is reloading a file into Emacs buffer called "revert"?

  • If you want Emacs to automatically reload files when they have been changed by another application, you can use global-auto-revert-mode. – Lindydancer Mar 7 '18 at 7:42
  • I think the name for the command wasn't chosen well. Reload seems like it would've been a better match. I don't think that whoever came up with the name, had the scenario where the file is modified outside Emacs in mind. More likely, the idea of reverting to the previously saved version would seem natural in environments where simultaneous editing of a file wasn't possible or very rare. – wvxvw Mar 7 '18 at 12:37
4

If I understand correctly, "revert" means to reload the file in the file system into the emacs buffer

This is correct.

(There are other details which you can read about in the documentation, including what "revert" means to non-file-visiting buffers; but broadly speaking your understanding is accurate.)

so the buffer will be updated with the latest change to the file made outside emacs.

More generally, so that the buffer will be updated with the contents of that file regardless of whether the file has been changed.

This is more obvious in the context of the revert-buffer command:

Consider that you have made a sequence of un-saved changes to the buffer, and you decide that you want to start over. Here, "revert" makes perfect sense -- you are going back to your starting point.

It's certainly true that other programs might have modified the file since you visited it in emacs; but that's not the scenario for which this command was named.

C-hf revert-buffer puts it like so:

Replace current buffer text with the text of the visited file on disk. This undoes all changes since the file was visited or saved. With a prefix argument, offer to revert from latest auto-save file, if that is more recent than the visited file.

While C-hig (emacs)Reverting says:

18.4 Reverting a Buffer

If you have made extensive changes to a file-visiting buffer and then change your mind, you can “revert” the changes and go back to the saved version of the file. To do this, type ‘M-x revert-buffer’. Since reverting unintentionally could lose a lot of work, Emacs asks for confirmation first.

Consequently, "revert" is the common terminology for making the buffer contents match the saved file contents; and it applies even if the revision you are "reverting" to turns out to have been written by something other than Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.