linuxemacstext-editorfedoraxemacs

Autosaving on emacs or xemacs files (preferably on loss of focus)


Ideally I want to replicate with emacs functionality from TextMate, whereby on loss of focus i.e. I click away from the buffer, my file saves.

If this isn't possible, I want to customize emacs so that it will autosave the file for every character I write. When I say this I don't mean I want to autosave to the ~ backup files. I want to save the file I am currently working on.

I am working on a Fedora VM.

Note I am not looking for a backup or autosave. I want the file I am actually in to save, so that if I loaded the html file I am editing in a web browser it would reflect my new changes without me having to explicitly change it.


Solution

  • As far as I know GNU Emacs does not have a hook for loss of focus, but window managers usually provide a way to detect a change of the active application window. If you find out how you can do it with your window manager then it's only a matter of calling emacsclient and telling the running emacs to save the current buffer.