branch: externals/orderless
commit b059c15911894035eba8cf097699dbf86d6c5c97
Author: Omar Antolín <[email protected]>
Commit: Omar Antolín <[email protected]>
Make orderless-prefixes more like partial-completion
---
README.org | 11 ++++++-----
orderless.el | 12 ++++++------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index 8d4c6c1563..b6cc4ef117 100644
--- a/README.org
+++ b/README.org
@@ -4,7 +4,7 @@ This package provides an =orderless= completion style that
divides the
pattern into space-separated components, and matches candidates that
match all of the components in any order. Each component can match in
any one of several ways: literally, as a regexp, as an initialism, in
-the flex style, or as hyphenated word prefixes. By default, regexp and
+the flex style, or as multiple word prefixes. By default, regexp and
initialism matches are enabled.
Completion styles like =orderless= are used as entries in the variables
@@ -60,12 +60,13 @@ define new matching styles. The predefined ones are:
This maps =abc= to =a.*b.*c=.
-- orderless-prefixes :: the component is split on hyphens and slashes
- and each piece must be a word prefix in the candidate, occurring in
- that order.
+- orderless-prefixes :: the component is split at word endings and
+ each piece must match at a word boundary in the candidate, occurring
+ in that order.
This is similar to the built-in =partial-completion= completion-style.
- For example =re-re= matches =query-replace-regexp= and =recode-region=.
+ For example, =re-re= matches =query-replace-regexp=, =recode-region= and
+ =magit-remote-list-refs=; =f-d.t= matches =final-draft.txt=.
The variable =orderless-component-matching-style= should be set to a
list of the desired styles to use. By default it enables the regexp
diff --git a/orderless.el b/orderless.el
index 9a20817577..4965b140a7 100644
--- a/orderless.el
+++ b/orderless.el
@@ -156,13 +156,13 @@ candidate, in that order, at the beginning of words."
(cl-loop for char across component collect `(seq word-start ,char))))
(defun orderless-prefixes (component)
- "Match a component as slash-or-hyphen-separated word prefixes.
-The COMPONENT is split on slashes and hyphens, and each piece
-must match a prefix of a word in the candidate. This is similar
-to the `partial-completion' completion style."
+ "Match a component as multiple word prefixes.
+The COMPONENT is split at word endings, and each piece must match
+at a word boundary in the candidate. This is similar to the
+`partial-completion' completion style."
(orderless--anything-between
- (cl-loop for prefix in (split-string component "[/-]")
- collect `(seq word-start ,prefix))))
+ (cl-loop for prefix in (split-string component "\\>" t)
+ collect `(seq word-boundary ,prefix))))
(defun orderless--highlight-matches (regexps string)
"Highlight a match of each of the REGEXPS in STRING.