I want to have all my file buffers always synchronized with the file content on disk. Is is possible? (preferably as a mode)
If you think it is unsafe, than I will just say that emacs undo + git is more than enough for me and I find explicit saving and reverting (if other program changes the file) obsolete safety feature.
To save the file you are editing, type C-x C-s or select Save Buffer from the Files menu.
One use of Auto Revert mode is to “tail” a file such as a system log, so that changes made to that file by other programs are continuously displayed. To do this, just move the point to the end of the buffer, and it will stay there as the file contents change.
If you wish to mark the buffer as visiting a different file and save it right away, use C-x C-w ( write-file ). This is equivalent to set-visited-file-name followed by C-x C-s , except that C-x C-w asks for confirmation if the file exists.
Quit, cancel, open, save, save as: C-x C-c : Quit Emacs. C-g : Cancel the current action (use when there's part of a key sequence showing in the minibuffer and you want out) C-x C-f : Open a file (whether or not it already exists) C-x C-s : Save a file.
To bring it all together:
If you want auto-saving to be done in the visited file rather than in a separate auto-save file, set the variable
auto-save-visited-file-name
to a non-nil value. In this mode, there is no real difference between auto-saving and explicit saving.
http://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Save-Files.html#Auto-Save-Files
This makes your auto-saves go into the file you are working on, and not an external one.
Then you can set auto-save-interval
to 1, and enable global-auto-revert-mode
and you're all set.
I think that does it for you...
Set the "auto-save-interval" to 1. That will save after each character you type. It will save to the "save" file, rather than the actual file, but your work will be protected.
Another option is this: http://www.litchie.net/programs/real-auto-save.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With