diff options
| author | Omar Antolín <omar.antolin@gmail.com> | 2020-04-23 00:56:51 -0500 |
|---|---|---|
| committer | Omar Antolín <omar.antolin@gmail.com> | 2020-04-23 00:56:51 -0500 |
| commit | b059c15911894035eba8cf097699dbf86d6c5c97 (patch) | |
| tree | f4d34c3a10330c6e681ae23ac8c11d5bdf9c6d1a | |
| parent | d0143484d08f72013885ef43fdd504fed21103c3 (diff) | |
Make orderless-prefixes more like partial-completion
| -rw-r--r-- | README.org | 11 | ||||
| -rw-r--r-- | orderless.el | 12 |
2 files changed, 12 insertions, 11 deletions
@@ -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 9a20817..4965b14 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. |
