Replace Prelude's auto-save functionality with super-save

Prelude's auto-save logic was extracted in the super-save packaged
and polished a bit there.
This commit is contained in:
Bozhidar Batsov 2018-09-28 16:57:17 +03:00
parent fef1988eac
commit e7b42d1e5c
2 changed files with 3 additions and 27 deletions

View file

@ -149,33 +149,8 @@
;; automatically save buffers associated with files on buffer switch ;; automatically save buffers associated with files on buffer switch
;; and on windows switch ;; and on windows switch
(defun prelude-auto-save-command () (require 'super-save)
"Save the current buffer if `prelude-auto-save' is not nil." (super-save-mode +1)
(when (and prelude-auto-save
buffer-file-name
(buffer-modified-p (current-buffer))
(file-writable-p buffer-file-name))
(save-buffer)))
(defmacro advise-commands (advice-name commands class &rest body)
"Apply advice named ADVICE-NAME to multiple COMMANDS.
The body of the advice is in BODY."
`(progn
,@(mapcar (lambda (command)
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
,@body))
commands)))
;; advise all window switching functions
(advise-commands "auto-save"
(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right)
before
(prelude-auto-save-command))
(add-hook 'mouse-leave-buffer-hook 'prelude-auto-save-command)
(add-hook 'focus-out-hook 'prelude-auto-save-command)
(defadvice set-buffer-major-mode (after set-major-mode activate compile) (defadvice set-buffer-major-mode (after set-major-mode activate compile)
"Set buffer major mode according to `auto-mode-alist'." "Set buffer major mode according to `auto-mode-alist'."

View file

@ -80,6 +80,7 @@
operate-on-number operate-on-number
smartparens smartparens
smartrep smartrep
super-save
undo-tree undo-tree
volatile-highlights volatile-highlights
which-key which-key