el/dot-emacs.el (mdw-switch-window-configuration): Print a message afterwards.
[profile] / el / dot-emacs.el
index c7849f3..9088736 100644 (file)
@@ -319,13 +319,17 @@ prevailing configuration."
           (or (and (consp arg) (= (car arg) 4) (= (car arg) 64))
               (and (integerp arg) (not (zerop (logand arg 1))))))))
 
-  (let ((current-windows (list (current-window-configuration)
+  (let ((previous mdw-current-window-configuration)
+       (current-windows (list (current-window-configuration)
                               (point-marker)))
        (register-value (and register (get-register register))))
     (when (and mdw-current-window-configuration (not no-save))
       (set-register mdw-current-window-configuration current-windows))
     (cond ((null register)
-          (setq mdw-current-window-configuration nil))
+          (setq mdw-current-window-configuration nil)
+          (if previous
+              (message "Left window configuration `%c'." previous)
+            (message "Nothing to do!")))
          ((not (or (null register-value)
                    (and (consp register-value)
                         (window-configuration-p (car register-value))
@@ -334,10 +338,14 @@ prevailing configuration."
           (error "Register `%c' is not a window configuration" register))
          (t
           (cond ((null register-value)
-                 (set-register register current-windows))
+                 (set-register register current-windows)
+                 (message "Started new window configuration `%c'."
+                          register))
                 (t
                  (set-window-configuration (car register-value))
-                 (goto-char (cadr register-value))))
+                 (goto-char (cadr register-value))
+                 (message "Switched to window configuration `%c'."
+                          register)))
           (setq mdw-current-window-configuration register)))))
 
 ;; Don't raise windows unless I say so.
@@ -5166,6 +5174,29 @@ there is sadness."
       (smerge-mode 1))))
 (add-hook 'find-file-hook 'mdw-try-smerge t)
 
+(defcustom mdw-magit-new-window-modes
+  '(magit-diff-mode
+    magit-log-mode
+    magit-process-mode
+    magit-revision-mode
+    magit-stash-mode
+    magit-status-mode)
+  "Magit modes which should cause a new window to be used."
+  :type '(repeat symbol))
+
+(defun mdw-display-magit-buffer (buffer)
+  "Like `magit-display-buffer-traditional'.
+But uses `mdw-magit-new-window-modes' for its list of modes
+rather than baking the list into the function."
+  (display-buffer buffer
+                 (if (and (not mdw-designated-window)
+                          (derived-mode-p 'magit-mode)
+                          (not (memq (with-current-buffer buffer major-mode)
+                                     mdw-magit-new-window-modes)))
+                     '(display-buffer-same-window . nil)
+                   nil)))
+(setq magit-display-buffer-function 'mdw-display-magit-buffer)
+
 ;;;--------------------------------------------------------------------------
 ;;; GUD, and especially GDB.