tags:

views:

165

answers:

3

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.

+1  A: 

Sounds like you want auto-revert-mode (or more likely global-auto-revert-mode).

Nicholas Riley
Solves half of the problem, what about global-auto-save-mode?
Łukasz Lew
Ah, by "I don't need saving" I assumed you never wanted to write to the file.
Nicholas Riley
+2  A: 

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

swillden
Also see: http://bryan-murdock.blogspot.com/2008/03/beat-save-habit.html , the EmacsWiki: http://www.emacswiki.org/emacs/AutoSave , and (pointlessly): http://shreevatsa.wordpress.com/2008/01/22/emacs-auto-save/
ShreevatsaR
+5  A: 

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%5Fnode/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...

Paul McMillan
Nice. But I want this only for files that are under git's supervision, is it possible to automatize this?
Łukasz Lew
You can probably modify your local copy of git.el to enable these changes only when you're editing git controlled files.
Paul McMillan
or use something like eproject to configure that on a project-type basis
l0st3d