[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 51bab59 1/6: More robust window configuration cha
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/corfu 51bab59 1/6: More robust window configuration change handling |
Date: |
Thu, 29 Apr 2021 06:51:17 -0400 (EDT) |
branch: externals/corfu
commit 51bab59d99113b2417da2871f3240a24fd3d5834
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
More robust window configuration change handling
---
corfu.el | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/corfu.el b/corfu.el
index 0e054a8..58383b0 100644
--- a/corfu.el
+++ b/corfu.el
@@ -458,18 +458,24 @@ Set to nil in order to disable confirmation."
(defun corfu--pre-command-hook ()
"Insert selected candidate unless keep alive command."
+ (add-hook 'window-configuration-change-hook #'corfu--hide)
(when corfu--overlay
(delete-overlay corfu--overlay)
(setq corfu--overlay nil))
(unless (or (< corfu--index 0) (corfu--keep-alive-p))
(corfu--insert 'exact)))
-(defun corfu--window-change-hook ()
- "Terminate completion when window configuration changed."
- (completion-in-region-mode -1))
+(defun corfu--hide ()
+ "Hide Corfu popup."
+ (when (frame-live-p corfu--frame)
+ (make-frame-invisible corfu--frame)
+ (with-current-buffer (window-buffer (frame-root-window corfu--frame))
+ (erase-buffer)))
+ (remove-hook 'window-configuration-change-hook #'corfu--hide))
(defun corfu--post-command-hook ()
"Refresh Corfu after last command."
+ (remove-hook 'window-configuration-change-hook #'corfu--hide)
(or (pcase completion-in-region--data
(`(,beg ,end ,_table ,_pred)
(when (and (eq (marker-buffer beg) (current-buffer)) (<= beg (point)
end))
@@ -521,18 +527,13 @@ Set to nil in order to disable confirmation."
(let ((config (current-window-configuration))
(other other-window-scroll-buffer)
(restore (make-symbol "corfu--restore")))
- (remove-hook 'window-configuration-change-hook
- #'corfu--window-change-hook 'local)
(fset restore
(lambda ()
(when (eq this-command #'corfu-abort)
(setq this-command #'ignore))
(remove-hook 'pre-command-hook restore)
(setq other-window-scroll-buffer other)
- (set-window-configuration config)
- (redisplay) ;; force configuration change
- (add-hook 'window-configuration-change-hook
- #'corfu--window-change-hook nil 'local)))
+ (set-window-configuration config)))
(add-hook 'pre-command-hook restore)))
;; Company support, taken from `company.el', see `company-show-doc-buffer'.
@@ -623,20 +624,15 @@ Set to nil in order to disable confirmation."
"Setup Corfu completion state."
(setq corfu--extra-properties completion-extra-properties)
(setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist)
corfu-map)
- (add-hook 'window-configuration-change-hook #'corfu--window-change-hook nil
'local)
(add-hook 'pre-command-hook #'corfu--pre-command-hook nil 'local)
(add-hook 'post-command-hook #'corfu--post-command-hook nil 'local))
(defun corfu--teardown ()
"Teardown Corfu."
- (remove-hook 'window-configuration-change-hook #'corfu--window-change-hook
'local)
+ (corfu--hide)
(remove-hook 'pre-command-hook #'corfu--pre-command-hook 'local)
(remove-hook 'post-command-hook #'corfu--post-command-hook 'local)
(when corfu--overlay (delete-overlay corfu--overlay))
- (when (frame-live-p corfu--frame)
- (make-frame-invisible corfu--frame)
- (with-current-buffer (window-buffer (frame-root-window corfu--frame))
- (erase-buffer)))
(mapc #'kill-local-variable corfu--state-vars))
(defun corfu--mode-hook ()
- [elpa] externals/corfu updated (e8180e0 -> f5b6c5d), Protesilaos Stavrou, 2021/04/29
- [elpa] externals/corfu e39ac1f 4/6: Call corfu-abort, Protesilaos Stavrou, 2021/04/29
- [elpa] externals/corfu 36f51ad 2/6: Simplify state management, Protesilaos Stavrou, 2021/04/29
- [elpa] externals/corfu a605fc3 5/6: Delete overlay before update, Protesilaos Stavrou, 2021/04/29
- [elpa] externals/corfu 51bab59 1/6: More robust window configuration change handling,
Protesilaos Stavrou <=
- [elpa] externals/corfu 1763cb9 3/6: Revert "Simplify state management", Protesilaos Stavrou, 2021/04/29
- [elpa] externals/corfu f5b6c5d 6/6: Renamings, Protesilaos Stavrou, 2021/04/29