From 935db6d62bb2e4e538fecc8402e23a5d83d10d86 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 6 Mar 2012 19:23:04 +0200 Subject: [PATCH] auto-save files on window or buffer switch --- modules/prelude-core.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/prelude-core.el b/modules/prelude-core.el index c766496..ff77424 100644 --- a/modules/prelude-core.el +++ b/modules/prelude-core.el @@ -360,5 +360,20 @@ there's a region, all lines that region covers will be duplicated." (global-set-key [M-left] 'left-word) (message "Arrow keys navigation in buffers in now allowed.")) +;; automatically save buffers associated with files on buffer switch +;; and on windows switch +(defadvice switch-to-buffer (before save-buffer-now activate) + (when buffer-file-name (save-buffer))) +(defadvice other-window (before other-window-now activate) + (when buffer-file-name (save-buffer))) +(defadvice windmove-up (before other-window-now activate) + (when buffer-file-name (save-buffer))) +(defadvice windmove-down (before other-window-now activate) + (when buffer-file-name (save-buffer))) +(defadvice windmove-left (before other-window-now activate) + (when buffer-file-name (save-buffer))) +(defadvice windmove-right (before other-window-now activate) + (when buffer-file-name (save-buffer))) + (provide 'prelude-core) ;;; prelude-core.el ends here