0

When I try to save a buffer back to a file:

install-packages.sh has changed since visited or saved. Save anyway? (yes or no)

I don't know why it happens, but I also see #install-packages.sh# exists in the same directory.

What do yes and no mean? Do they perform three way merge?

I would like to keep changes from different sources.

2

Yes means save the file, overwriting what's on disk. No means do nothing.

The file #install-packages.sh# is the auto-save file. It's there in case emacs crashes before you saved the buffer. (It is removed when you do save the buffer.)

To see the differences between what's in the buffer and what's on disk, run M-x diff-buffer-with-file. The resulting window runs Diff mode, which will let you resolve the situation. Or you can just decide to save the file anyway, if you don't want to keep the externally caused chances.

1

It happens because the file you're visiting has changed on disk and there's a mismatch between what's in the Emacs buffer and what's on disk.

When you open a file, Emacs makes a copy in memory. It's not until you save the file that the changes in Emacs are written to disk. That is, the file is not locked during the editing process. It's therefore possible for an underlying file to change at the same time you're editing it. For instance, consider viewing a system log. A background process may update the log with new information while you're accessing the log with Emacs. If you tried to save, Emacs would warn you about the difference between what you see in Emacs versus what the log file now contains.

Saying yes will overwrite the file on disk with what you see in Emacs. Saying no keeps what is currently on disk. An alternative in this situation is to run write-file, C-x C-w, which is basically "Save as...".

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.