summaryrefslogtreecommitdiff
path: root/orderless.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2025-11-21 17:54:52 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2025-11-21 18:13:24 +0100
commitecf6a94df717791f85be6449f953ddef29244a15 (patch)
treec3ad1bfb8009cbd0334947a0ac55e3d077db97a5 /orderless.el
parent9cf1c90e2501566ceba59f3220b4630995004efd (diff)
orderless-compile, orderless-escapable-split-on-space: Preserve empty components
Fix #55 Only drop the last empty component. The new behavior has the following effects: 1. The first empty component is preserved and can be treated specifically as requested in #55. The assumption is that a separator at the beginning is intentional. (cdr (orderless-compile " ")) => ("") (cdr (orderless-compile " foo")) => ("" "foo") 2. Completely blank input will compile to an empty regexp list. This is important for completion command startup performance: (cdr (orderless-compile "")) => nil 3. When separating components, the last separator will not lead to an intermediate artificial empty component, as long as the user has not finished typing. For example the user types the words "foo bar": (cdr (orderless-compile "foo")) => ("foo") (cdr (orderless-compile "foo ")) => ("foo") (cdr (orderless-compile "foo bar")) => ("foo" "bar")
Diffstat (limited to 'orderless.el')
-rw-r--r--orderless.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/orderless.el b/orderless.el
index bd34856..1ff379e 100644
--- a/orderless.el
+++ b/orderless.el
@@ -370,7 +370,7 @@ converted to a list of regexps according to the value of
"\\\\\\\\\\|\\\\ "
(lambda (x) (if (equal x "\\ ") (string 0) x))
string 'fixedcase 'literal)
- " +" t)))
+ " +")))
(defun orderless--dispatch (dispatchers default string index total)
"Run DISPATCHERS to compute matching styles for STRING.
@@ -457,9 +457,10 @@ string as argument."
(unless dispatchers (setq dispatchers orderless-style-dispatchers))
(cl-loop
with predicate = nil
- with components = (if (functionp orderless-component-separator)
- (funcall orderless-component-separator pattern)
- (split-string pattern orderless-component-separator t))
+ with temp = (if (functionp orderless-component-separator)
+ (funcall orderless-component-separator pattern)
+ (split-string pattern orderless-component-separator))
+ with components = (if (equal (car (last temp)) "") (nbutlast temp) temp)
with total = (length components)
for comp in components and index from 0
for (pred . regexp) = (orderless--compile-component