How to automatically save files on lose focus in Emacs

前端 未结 5 1108
日久生厌
日久生厌 2020-12-09 16:23

Is it possible to configure Emacs, so that it saves all files when the emacs window loses focus?

5条回答
  •  生来不讨喜
    2020-12-09 17:11

    I added focus hooks to Gnu Emacs 24.4.

    They are called focus-in-hook and focus-out-hook.

    You can add

    (defun save-all ()
      (interactive)
      (save-some-buffers t))
    
    (add-hook 'focus-out-hook 'save-all)
    

    to your .emacs file and it should save all files on loss of focus.

提交回复
热议问题