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

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

[elpa] externals/corfu 96f4c2675d 2/3: Extract function corfu--continue-


From: ELPA Syncer
Subject: [elpa] externals/corfu 96f4c2675d 2/3: Extract function corfu--continue-p
Date: Fri, 14 Oct 2022 04:57:25 -0400 (EDT)

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

    Extract function corfu--continue-p
---
 corfu.el | 70 ++++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/corfu.el b/corfu.el
index 2da1c42d99..4ec7051c51 100644
--- a/corfu.el
+++ b/corfu.el
@@ -910,41 +910,45 @@ See `corfu-separator' for more details."
   (interactive)
   (insert corfu-separator))
 
+(defun corfu--continue-p ()
+  "Continue completion?"
+  (pcase completion-in-region--data
+    (`(,beg ,end . ,_)
+       (and (eq (marker-buffer beg) (current-buffer))
+            ;; Check ranges
+            (let ((pt (point)))
+              (and (<= beg pt end)
+                   (save-excursion
+                     (goto-char beg)
+                     (let ((inhibit-field-text-motion t))
+                       (<= (line-beginning-position) pt 
(line-end-position))))))
+            (or
+             ;; TODO We keep alive Corfu if a `overriding-terminal-local-map' 
is
+             ;; installed, for example the `universal-argument-map'. It would 
be good to
+             ;; think about a better criterion instead. Unfortunately relying 
on
+             ;; `this-command' alone is not sufficient, since the value of 
`this-command'
+             ;; gets clobbered in the case of transient keymaps.
+             overriding-terminal-local-map
+             ;; Check if it is an explicitly listed continue command
+             (corfu--match-symbol-p corfu-continue-commands this-command)
+             (and
+              ;; Check for empty input
+              (or (not corfu--input) (< beg end))
+              ;; Check separator or predicate
+              (or (not corfu-quit-at-boundary)
+                  (and (eq corfu-quit-at-boundary 'separator)
+                       (or (eq this-command #'corfu-insert-separator)
+                           ;; with separator, any further chars allowed
+                           (seq-contains-p (car corfu--input) 
corfu-separator)))
+                  (funcall completion-in-region-mode--predicate))))))))
+
 (defun corfu--post-command ()
   "Refresh Corfu after last command."
-  (or (pcase completion-in-region--data
-        (`(,beg ,end . ,_)
-         (when (let ((pt (point)))
-                 (and (eq (marker-buffer beg) (current-buffer))
-                      ;; Check ranges
-                      (<= beg pt end)
-                      (save-excursion
-                        (goto-char beg)
-                        (let ((inhibit-field-text-motion t))
-                          (<= (line-beginning-position) pt 
(line-end-position))))
-                      (or
-                       ;; TODO We keep alive Corfu if a 
`overriding-terminal-local-map' is
-                       ;; installed, for example the `universal-argument-map'. 
It would be good to
-                       ;; think about a better criterion instead. 
Unfortunately relying on
-                       ;; `this-command' alone is not sufficient, since the 
value of `this-command'
-                       ;; gets clobbered in the case of transient keymaps.
-                       overriding-terminal-local-map
-                       ;; Check if it is an explicitly listed continue command
-                       (corfu--match-symbol-p corfu-continue-commands 
this-command)
-                       (and
-                        ;; Check for empty input
-                        (or (not corfu--input) (< beg end))
-                        ;; Check separator or predicate
-                        (or (not corfu-quit-at-boundary)
-                            (and (eq corfu-quit-at-boundary 'separator)
-                                 (or (eq this-command #'corfu-insert-separator)
-                                     ;; with separator, any further chars 
allowed
-                                     (seq-contains-p (car corfu--input) 
corfu-separator)))
-                            (funcall completion-in-region-mode--predicate))))))
-           (corfu--exhibit)
-           t)))
-      (corfu-quit))
-  (when corfu-auto (corfu--auto-post-command)))
+  (if (corfu--continue-p)
+      (corfu--exhibit)
+    (corfu-quit))
+  (when corfu-auto
+    (corfu--auto-post-command)))
 
 (defun corfu--goto (index)
   "Go to candidate with INDEX."



reply via email to

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