How to automatically save files on lose focus in Emacs

前端 未结 5 1110
日久生厌
日久生厌 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:06

    […] the feature I am talking about is from Scribes. It is very convient when editing html and the like, you don't have to press C-x C-s anymore, you just change the window and check your browser.

    In that case, instead of switching to the browser application, order Emacs to load the browser application (C-c C-v or M-x browse-url-of-buffer). With this method, you can write your own function that saves the buffer and then brings the browser up, like:

    (defun my-browse-url-of-buffer ()
      "Save current buffer and view its content in browser."
      (interactive)
      (save-buffer)
      (browse-url-of-buffer))
    

    And hook it to a convenient binding.

    Or you can still use the html-autoview-mode that each time you saves the buffer, automatically loads the file into your favorite browser.

提交回复
热议问题