emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/which-key a8da871 4/6: Merge pull request #321 from fre


From: ELPA Syncer
Subject: [elpa] externals/which-key a8da871 4/6: Merge pull request #321 from fredericgiquel/preserve-window-configuration
Date: Thu, 25 Nov 2021 21:57:37 -0500 (EST)

branch: externals/which-key
commit a8da8714cd457009bcbb4be82573765226576f4c
Merge: 4790a14 507292d
Author: Justin Burkett <justin@burkett.cc>
Commit: GitHub <noreply@github.com>

    Merge pull request #321 from fredericgiquel/preserve-window-configuration
    
    Preserve window configuration
---
 which-key.el | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/which-key.el b/which-key.el
index 470d173..1daebc9 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
   :group 'which-key
   :type 'boolean)
 
+(defcustom which-key-preserve-window-configuration nil
+  "If non-nil, save window configuration before which-key buffer is shown
+and restore it after which-key buffer is hidden. It prevents which-key from
+changing window position of visible buffers.
+Only takken into account when popup type is side-window."
+  :group
+  'which-key
+  :type 'boolean)
+
 (defvar which-key-C-h-map
   (let ((map (make-sparse-keymap)))
     (dolist (bind `(("\C-a" . which-key-abort)
@@ -655,6 +664,8 @@ update.")
   prefix
   prefix-title)
 
+(defvar which-key--saved-window-configuration nil)
+
 (defun which-key--rotate (list n)
   (let* ((len (length list))
          (n (if (< n 0) (+ len n) n))
@@ -1096,7 +1107,11 @@ total height."
   (when (buffer-live-p which-key--buffer)
     ;; in case which-key buffer was shown in an existing window, `quit-window'
     ;; will re-show the previous buffer, instead of closing the window
-    (quit-windows-on which-key--buffer)))
+    (quit-windows-on which-key--buffer)
+    (when (and which-key-preserve-window-configuration
+               which-key--saved-window-configuration)
+      (set-window-configuration which-key--saved-window-configuration)
+      (setq which-key--saved-window-configuration nil))))
 
 (defun which-key--hide-buffer-frame ()
   "Hide which-key buffer when frame popup is used."
@@ -1135,6 +1150,9 @@ call signature in different emacs versions"
 
 (defun which-key--show-buffer-side-window (act-popup-dim)
   "Show which-key buffer when popup type is side-window."
+  (when (and which-key-preserve-window-configuration
+             (not which-key--saved-window-configuration))
+    (setq which-key--saved-window-configuration 
(current-window-configuration)))
   (let* ((height (car act-popup-dim))
          (width (cdr act-popup-dim))
          (alist



reply via email to

[Prev in Thread] Current Thread [Next in Thread]