Add lots of orderless stuff
This commit is contained in:
parent
a6793e3e53
commit
eb46c6a277
52
init.el
52
init.el
|
@ -1236,7 +1236,57 @@ if ripgrep is installed, otherwise `consult-grep'."
|
|||
:host github
|
||||
:repo "oantolin/orderless"))
|
||||
(require 'orderless)
|
||||
(:option (append completion-styles) 'orderless))
|
||||
|
||||
(:option (append completion-styles) 'orderless
|
||||
orderless-component-separator #'orderless-escapable-split-on-space
|
||||
orderless-style-dispatchers '(acdw/orderless-dispatch))
|
||||
|
||||
(defun fix-dollar (args)
|
||||
(if (string-suffix-p "$" (car args))
|
||||
(list (concat (substring (car args) 0 -1) "[\x100000-\x10FFFD]*$"))
|
||||
args))
|
||||
(advice-add #'orderless-regexp :filter-args #'fix-dollar)
|
||||
|
||||
(defun acdw/orderless-dispatch (pattern _index _total)
|
||||
"My custom dispatcher for `orderless'."
|
||||
(cond
|
||||
;; Ensure that $ works with Consult commands, which add disambiguation
|
||||
;; suffixes -- see `fix-dollar'
|
||||
((string-suffix-p "$" pattern)
|
||||
`(orderless-regexp . ,(concat (substring pattern 0 -1)
|
||||
"[\x100000-\x10FFFD]*$")))
|
||||
;; File extensions
|
||||
((string-match-p "\\`\\.." pattern)
|
||||
`(orderless-regexp . ,(concat "\\." (substring pattern 1)
|
||||
"[\x100000-\x10FFFD]*$")))
|
||||
;; Ignore single !
|
||||
((string= "!" pattern)
|
||||
`(orderless-literal . ""))
|
||||
;; Character folding
|
||||
((string-prefix-p "%" pattern)
|
||||
`(char-fold-to-regexp . ,(substring pattern 1)))
|
||||
((string-suffix-p "%" pattern)
|
||||
`(char-fold-to-regexp . ,(substring pattern 0 -1)))
|
||||
;; Without literal
|
||||
((string-prefix-p "!" pattern)
|
||||
`(orderless-without-literal . ,(substring pattern 1)))
|
||||
((string-suffix-p "!" pattern)
|
||||
`(orderless-without-literal . ,(substring pattern 0 -1)))
|
||||
;; Initialism matching
|
||||
((string-prefix-p "`" pattern)
|
||||
`(orderless-initialism . ,(substring pattern 1)))
|
||||
((string-suffix-p "`" pattern)
|
||||
`(orderless-initialism . ,(substring pattern 0 -1)))
|
||||
;; Literal matching
|
||||
((string-prefix-p "=" pattern)
|
||||
`(orderless-literal . ,(substring pattern 1)))
|
||||
((string-suffix-p "=" pattern)
|
||||
`(orderless-literal . ,(substring pattern 0 -1)))
|
||||
;; Flex matching
|
||||
((string-prefix-p "~" pattern)
|
||||
`(orderless-flex . ,(substring pattern 1)))
|
||||
((string-suffix-p "~" pattern)
|
||||
`(orderless-flex . ,(substring pattern 0 -1))))))
|
||||
|
||||
(setup (:straight org)
|
||||
(:straight org-contrib)
|
||||
|
|
Loading…
Reference in New Issue
Block a user