diff options
author | jao <jao@gnu.org> | 2021-12-03 02:09:31 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2021-12-03 02:09:31 +0000 |
commit | 932f3f34745ed376b5c63e90ebf75103f26f5d7c (patch) | |
tree | 3d114ace3d05859cc226b292485ae8aee76bc5df | |
parent | a83235f9be461e50f1d922f5f38ac9fe0b70bcc9 (diff) | |
download | elibs-932f3f34745ed376b5c63e90ebf75103f26f5d7c.tar.gz elibs-932f3f34745ed376b5c63e90ebf75103f26f5d7c.tar.bz2 |
orderless style dispatchers ftw
-rw-r--r-- | completion.org | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/completion.org b/completion.org index 0c14df1..c0b0a88 100644 --- a/completion.org +++ b/completion.org @@ -30,11 +30,26 @@ (use-package orderless :ensure t :init + (defun jao-orderless--first-initialism (pattern index _total) + (when (and (= index 0) (string-prefix-p "-" pattern)) + `(orderless-strict-full-initialism . ,(substring pattern 1)))) + + (defun jao-orderless--regexp (pattern _index _total) + (when (string-suffix-p "%" pattern) + `(orderless-regexp . ,(substring pattern 0 -1)))) + + (defun jao-orderless--without-if-bang (pattern _index _total) + (cond ((equal "!" pattern) '(orderless-literal . "")) + ((string-prefix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 1))))) + (setq completion-styles '(orderless) orderless-skip-highlighting nil - orderless-component-separator "[ -/]+" - orderless-matching-styles - '(orderless-literal orderless-initialism orderless-regexp))) + orderless-component-separator " +" + orderless-matching-styles '(orderless-literal orderless-prefixes) + orderless-style-dispatchers '(jao-orderless--first-initialism + jao-orderless--regexp + jao-orderless--without-if-bang))) #+end_src * corfu #+begin_src emacs-lisp |