branch: externals/corfu commit 58ebf52323cac085d2058eb78d0f9f0e57e4972e Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add corfu-respect-boundary --- README.org | 10 ++++------ corfu.el | 12 +++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index e3b12d4..1e1be34 100644 --- a/README.org +++ b/README.org @@ -37,8 +37,9 @@ will fall back to the default setting of the ~completion-in-region-function~. - The current candidate is inserted with =TAB= and selected with =RET= - Candidates sorting by prefix, string length and alphabetically - Completion is automatically terminated after candidate selection -- Filter string can contain arbitrary characters and spaces (needed - when filtering with the [[https://github.com/oantolin/orderless][Orderless]] completion style) +- Filter string can contain arbitrary characters and spaces, if + ~corfu-respect-boundary~ is nil. This is needed when filtering with the + [[https://github.com/oantolin/orderless][Orderless]] completion style. - Deferred completion style highlighting for performance - Jumping to location/documentation of current candidate (Company extension) - Support for ~annotation-function~ and ~affixation-function~ @@ -129,7 +130,7 @@ The keymap defines the following remappings and bindings: Corfu works well together with all packages providing code completion via the ~completion-at-point-functions~. Furthermore it supports various completion styles, including the advanced [[https://github.com/oantolin/orderless][Orderless]] completion style, where the filtering -expressions are separated by spaces. +expressions are separated by spaces (see ~corfu-respect-boundary~). You may also want to look into my [[https://github.com/minad/vertico][Vertico]] package. Vertico is the minibuffer counterpart of Corfu. @@ -142,9 +143,6 @@ Corfu works in most scenarios. However there are a few known technical caveats. - Corfu falls back to the default ~completion-in-region-function~ on non-graphical displays, since is displayed using child frames. - The abort handling could be improved, for example the input could be undone. -- The ~completion-in-region-mode-predicate~ is ignored in order to - give the completion style full control. The predicate asks the backend if - the starting point of the completion has changed. - Company kind icons, docsig and match data are not supported (~company-kind~, ~company-docsig~, ~company-match~). - No support for multi-backends like Company (Implement a multi-capf?). diff --git a/corfu.el b/corfu.el index b2c70bc..1e5b478 100644 --- a/corfu.el +++ b/corfu.el @@ -58,6 +58,13 @@ "Enable cycling for `corfu-next' and `corfu-previous'." :type 'boolean) +(defcustom corfu-respect-boundary nil + "Respect completion field boundaries. +If this variable is nil, Orderless filtering is facilitated since a filter +string with spaces is allowed. Otherwise the completion is terminated at the +word boundary." + :type 'boolean) + (defcustom corfu-no-match (propertize "No match" 'face 'italic) "Show this confirmation string if there is no match. Set to nil in order to disable confirmation." @@ -708,7 +715,10 @@ Set to nil in order to disable confirmation." ;; XXX Disable original predicate check, keep completion alive when ;; popup is shown. Since the predicate is set always, it is ensured ;; that `completion-in-region-mode' is turned on. - (completion-in-region-mode-predicate (lambda () t))) + (completion-in-region-mode-predicate + (or (and corfu-respect-boundary + completion-in-region-mode-predicate) + (lambda () t)))) (apply #'completion--in-region args)) (corfu--setup))) ;; XXX Warning this can result in an endless loop when `completion-in-region-function'