summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar AntolĂ­n Camarena <omar.antolin@gmail.com>2024-02-29 19:15:01 -0600
committerGitHub <noreply@github.com>2024-02-29 19:15:01 -0600
commit7545dc7c07d1465e9661209ca5930ae3f1a870a3 (patch)
tree9d828606cdba40f51ee9b2d10ab068c144f7e912
parent2e904412e4e31a0312d77dd7697d6a59faa627fe (diff)
parentc94c252ea8e53082f6f3ef3f37b44b3872a0825c (diff)
Merge pull request #166 from minad/fix-affix-dispatch
orderless-affix-dispatch: Do not error on empty string
-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.