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

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

[elpa] externals/corfu b2b9a2312f: Ensure that M-x completion-at-point R


From: ELPA Syncer
Subject: [elpa] externals/corfu b2b9a2312f: Ensure that M-x completion-at-point RET works (Fix #380)
Date: Fri, 13 Oct 2023 15:57:54 -0400 (EDT)

branch: externals/corfu
commit b2b9a2312f58117514724e729fda43efc4433ecd
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Ensure that M-x completion-at-point RET works (Fix #380)
---
 CHANGELOG.org |  1 +
 corfu.el      | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 07951fb19b..0afcc07947 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -4,6 +4,7 @@
 
 * Development
 
+- Bug fixes.
 - =corfu-quick=: Use a slightly different scheme to support more candidates.
 - =corfu-reset=: Quit immediately if input did not change.
 
diff --git a/corfu.el b/corfu.el
index d4a823bc7d..f155bbeb49 100644
--- a/corfu.el
+++ b/corfu.el
@@ -792,6 +792,13 @@ or if the last invoked command is not listed in
                             (seq-contains-p (car corfu--input) 
corfu-separator)))
                    (funcall completion-in-region-mode--predicate)))))))
 
+(defun corfu--window-change (_)
+  "Window and buffer change hook which quits Corfu."
+  (let ((buf (current-buffer))
+        (beg (car completion-in-region--data)))
+    (unless (and beg (eq buf (marker-buffer beg)) (eq buf (window-buffer)))
+      (corfu-quit))))
+
 (defun corfu--post-command ()
   "Refresh Corfu after last command."
   (if (corfu--continue-p)
@@ -820,8 +827,8 @@ or if the last invoked command is not listed in
   (activate-change-group (setq corfu--change-group (prepare-change-group)))
   (setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) 
corfu-map)
   (add-hook 'pre-command-hook #'corfu--prepare nil 'local)
-  (add-hook 'window-selection-change-functions #'corfu-quit nil 'local)
-  (add-hook 'window-buffer-change-functions #'corfu-quit nil 'local)
+  (add-hook 'window-selection-change-functions #'corfu--window-change nil 
'local)
+  (add-hook 'window-buffer-change-functions #'corfu--window-change nil 'local)
   (add-hook 'post-command-hook #'corfu--post-command)
   ;; Disable default post-command handling, since we have our own
   ;; checks in `corfu--post-command'.
@@ -1114,8 +1121,8 @@ AUTO is non-nil when initializing auto completion."
 (cl-defgeneric corfu--teardown ()
   "Tear-down Corfu."
   (corfu--popup-hide)
-  (remove-hook 'window-selection-change-functions #'corfu-quit 'local)
-  (remove-hook 'window-buffer-change-functions #'corfu-quit 'local)
+  (remove-hook 'window-selection-change-functions #'corfu--window-change 
'local)
+  (remove-hook 'window-buffer-change-functions #'corfu--window-change 'local)
   (remove-hook 'pre-command-hook #'corfu--prepare 'local)
   (remove-hook 'post-command-hook #'corfu--post-command)
   (when corfu--preview-ov (delete-overlay corfu--preview-ov))
@@ -1126,7 +1133,7 @@ AUTO is non-nil when initializing auto completion."
   "Sort LIST by length and alphabetically."
   (sort list #'corfu--length-string<))
 
-(defun corfu-quit (&rest _)
+(defun corfu-quit ()
   "Quit Corfu completion."
   (interactive)
   (completion-in-region-mode -1))



reply via email to

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