aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Giquel2021-08-18 10:17:28 +0200
committerFrédéric Giquel2021-08-18 10:17:28 +0200
commit507292dfde002d9d58c36034427feb8df2f421e1 (patch)
treebeb0dfeff4ead69aa21f1ad3ea4307b149aa86e8
parent2042f11eb1c036f3e4dcf3ce447e978b9ee64357 (diff)
downloademacs-507292dfde002d9d58c36034427feb8df2f421e1.tar.gz
emacs-507292dfde002d9d58c36034427feb8df2f421e1.zip
Add option (default off) to restore window configuration
-rw-r--r--which-key.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/which-key.el b/which-key.el
index 061afee73b8..6bbe2922bea 100644
--- a/which-key.el
+++ b/which-key.el
@@ -407,6 +407,15 @@ Note that `which-key-idle-delay' should be set before turning on
407 :group 'which-key 407 :group 'which-key
408 :type 'boolean) 408 :type 'boolean)
409 409
410(defcustom which-key-preserve-window-configuration nil
411 "If non-nil, save window configuration before which-key buffer is shown
412and restore it after which-key buffer is hidden. It prevents which-key from
413changing window position of visible buffers.
414Only takken into account when popup type is side-window."
415 :group
416 'which-key
417 :type 'boolean)
418
410(defvar which-key-C-h-map 419(defvar which-key-C-h-map
411 (let ((map (make-sparse-keymap))) 420 (let ((map (make-sparse-keymap)))
412 (dolist (bind `(("\C-a" . which-key-abort) 421 (dolist (bind `(("\C-a" . which-key-abort)
@@ -1099,7 +1108,8 @@ total height."
1099 ;; in case which-key buffer was shown in an existing window, `quit-window' 1108 ;; in case which-key buffer was shown in an existing window, `quit-window'
1100 ;; will re-show the previous buffer, instead of closing the window 1109 ;; will re-show the previous buffer, instead of closing the window
1101 (quit-windows-on which-key--buffer) 1110 (quit-windows-on which-key--buffer)
1102 (when which-key--saved-window-configuration 1111 (when (and which-key-preserve-window-configuration
1112 which-key--saved-window-configuration)
1103 (set-window-configuration which-key--saved-window-configuration) 1113 (set-window-configuration which-key--saved-window-configuration)
1104 (setq which-key--saved-window-configuration nil)))) 1114 (setq which-key--saved-window-configuration nil))))
1105 1115
@@ -1140,7 +1150,8 @@ call signature in different emacs versions"
1140 1150
1141(defun which-key--show-buffer-side-window (act-popup-dim) 1151(defun which-key--show-buffer-side-window (act-popup-dim)
1142 "Show which-key buffer when popup type is side-window." 1152 "Show which-key buffer when popup type is side-window."
1143 (unless which-key--saved-window-configuration 1153 (when (and which-key-preserve-window-configuration
1154 (not which-key--saved-window-configuration))
1144 (setq which-key--saved-window-configuration (current-window-configuration))) 1155 (setq which-key--saved-window-configuration (current-window-configuration)))
1145 (let* ((height (car act-popup-dim)) 1156 (let* ((height (car act-popup-dim))
1146 (width (cdr act-popup-dim)) 1157 (width (cdr act-popup-dim))