diff --git a/core/prelude-editor.el b/core/prelude-editor.el
index 79236a6..d9c813a 100644
--- a/core/prelude-editor.el
+++ b/core/prelude-editor.el
@@ -155,24 +155,20 @@ Will only occur if prelude-whitespace is also enabled."
              (file-writable-p buffer-file-name))
     (save-buffer)))
 
-(defadvice switch-to-buffer (before switch-buffer-now activate)
-  "Invoke `prelude-auto-save-command' before `switch-to-window'."
-  (prelude-auto-save-command))
-(defadvice other-window (before other-window-now activate)
-  "Invoke `prelude-auto-save-command' before `other-window'."
-  (prelude-auto-save-command))
-(defadvice windmove-up (before other-window-now activate)
-  "Invoke `prelude-auto-save-command' before `windmove-up'."
-  (prelude-auto-save-command))
-(defadvice windmove-down (before other-window-now activate)
-  "Invoke `prelude-auto-save-command' before `windmove-down'."
-  (prelude-auto-save-command))
-(defadvice windmove-left (before other-window-now activate)
-  "Invoke `prelude-auto-save-command' before `windmove-left'."
-  (prelude-auto-save-command))
-(defadvice windmove-right (before other-window-now activate)
-  "Invoke `prelude-auto-save-command' before `windmove-right'."
-  (prelude-auto-save-command))
+(defmacro advise-commands (advice-name commands &rest body)
+  "Apply advice named ADVICE-NAME to multiple COMMANDS.
+
+The body of the advice is in BODY."
+  `(progn
+     ,@(mapcar (lambda (command)
+                 `(defadvice ,command (before ,(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)
+                 (prelude-auto-save-command))
 
 (add-hook 'mouse-leave-buffer-hook 'prelude-auto-save-command)