summaryrefslogtreecommitdiff
path: root/orderless.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-02-29 20:26:35 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2024-02-29 20:26:35 +0100
commitc94c252ea8e53082f6f3ef3f37b44b3872a0825c (patch)
tree9d828606cdba40f51ee9b2d10ab068c144f7e912 /orderless.el
parent2e904412e4e31a0312d77dd7697d6a59faa627fe (diff)
orderless-affix-dispatch: Do not error on empty string
Diffstat (limited to 'orderless.el')
-rw-r--r--orderless.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/orderless.el b/orderless.el
index e9d9f31..0186241 100644
--- a/orderless.el
+++ b/orderless.el
@@ -160,19 +160,18 @@ If the COMPONENT starts or ends with one of the characters used
as a key in `orderless-affix-dispatch-alist', then that character
is removed and the remainder of the COMPONENT is matched in the
style associated to the character."
- (cond
- ;; Ignore single dispatcher character
- ((and (= (length component) 1) (alist-get (aref component 0)
- orderless-affix-dispatch-alist))
- #'ignore)
- ;; Prefix
- ((when-let ((style (alist-get (aref component 0)
- orderless-affix-dispatch-alist)))
- (cons style (substring component 1))))
- ;; Suffix
- ((when-let ((style (alist-get (aref component (1- (length component)))
- orderless-affix-dispatch-alist)))
- (cons style (substring component 0 -1))))))
+ (let ((len (length component))
+ (alist orderless-affix-dispatch-alist))
+ (when (> len 0)
+ (cond
+ ;; Ignore single dispatcher character
+ ((and (= len 1) (alist-get (aref component 0) alist)) #'ignore)
+ ;; Prefix
+ ((when-let ((style (alist-get (aref component 0) alist)))
+ (cons style (substring component 1))))
+ ;; Suffix
+ ((when-let ((style (alist-get (aref component (1- len)) alist)))
+ (cons style (substring component 0 -1))))))))
(defcustom orderless-style-dispatchers (list #'orderless-affix-dispatch)
"List of style dispatchers.