From 285fdd70c05b2d38c73f0998477d51e7a5360336 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 14 Oct 2022 10:15:09 +0200 Subject: Minor cleanup --- corfu.el | 55 ++++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/corfu.el b/corfu.el index 4ec7051..7c6e414 100644 --- a/corfu.el +++ b/corfu.el @@ -912,35 +912,32 @@ See `corfu-separator' for more details." (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)))))))) + (pcase-let ((pt (point)) + (`(,beg ,end . ,_) completion-in-region--data)) + (and beg end + (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 (or (not corfu--input) (< beg end)) ;; Check for empty input + (or (not corfu-quit-at-boundary) ;; Check separator or predicate + (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." -- cgit v1.0