about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el52
1 files changed, 51 insertions, 1 deletions
diff --git a/init.el b/init.el index c4bf72a..b848593 100644 --- a/init.el +++ b/init.el
@@ -1236,7 +1236,57 @@ if ripgrep is installed, otherwise `consult-grep'."
1236 :host github 1236 :host github
1237 :repo "oantolin/orderless")) 1237 :repo "oantolin/orderless"))
1238 (require 'orderless) 1238 (require 'orderless)
1239 (:option (append completion-styles) 'orderless)) 1239
1240 (:option (append completion-styles) 'orderless
1241 orderless-component-separator #'orderless-escapable-split-on-space
1242 orderless-style-dispatchers '(acdw/orderless-dispatch))
1243
1244 (defun fix-dollar (args)
1245 (if (string-suffix-p "$" (car args))
1246 (list (concat (substring (car args) 0 -1) "[\x100000-\x10FFFD]*$"))
1247 args))
1248 (advice-add #'orderless-regexp :filter-args #'fix-dollar)
1249
1250 (defun acdw/orderless-dispatch (pattern _index _total)
1251 "My custom dispatcher for `orderless'."
1252 (cond
1253 ;; Ensure that $ works with Consult commands, which add disambiguation
1254 ;; suffixes -- see `fix-dollar'
1255 ((string-suffix-p "$" pattern)
1256 `(orderless-regexp . ,(concat (substring pattern 0 -1)
1257 "[\x100000-\x10FFFD]*$")))
1258 ;; File extensions
1259 ((string-match-p "\\`\\.." pattern)
1260 `(orderless-regexp . ,(concat "\\." (substring pattern 1)
1261 "[\x100000-\x10FFFD]*$")))
1262 ;; Ignore single !
1263 ((string= "!" pattern)
1264 `(orderless-literal . ""))
1265 ;; Character folding
1266 ((string-prefix-p "%" pattern)
1267 `(char-fold-to-regexp . ,(substring pattern 1)))
1268 ((string-suffix-p "%" pattern)
1269 `(char-fold-to-regexp . ,(substring pattern 0 -1)))
1270 ;; Without literal
1271 ((string-prefix-p "!" pattern)
1272 `(orderless-without-literal . ,(substring pattern 1)))
1273 ((string-suffix-p "!" pattern)
1274 `(orderless-without-literal . ,(substring pattern 0 -1)))
1275 ;; Initialism matching
1276 ((string-prefix-p "`" pattern)
1277 `(orderless-initialism . ,(substring pattern 1)))
1278 ((string-suffix-p "`" pattern)
1279 `(orderless-initialism . ,(substring pattern 0 -1)))
1280 ;; Literal matching
1281 ((string-prefix-p "=" pattern)
1282 `(orderless-literal . ,(substring pattern 1)))
1283 ((string-suffix-p "=" pattern)
1284 `(orderless-literal . ,(substring pattern 0 -1)))
1285 ;; Flex matching
1286 ((string-prefix-p "~" pattern)
1287 `(orderless-flex . ,(substring pattern 1)))
1288 ((string-suffix-p "~" pattern)
1289 `(orderless-flex . ,(substring pattern 0 -1))))))
1240 1290
1241(setup (:straight org) 1291(setup (:straight org)
1242 (:straight org-contrib) 1292 (:straight org-contrib)