diff options
Diffstat (limited to 'lisp/acdw-consult.el')
-rw-r--r-- | lisp/acdw-consult.el | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lisp/acdw-consult.el b/lisp/acdw-consult.el new file mode 100644 index 0000000..e6995f5 --- /dev/null +++ b/lisp/acdw-consult.el | |||
@@ -0,0 +1,37 @@ | |||
1 | ;;; acdw-consult.el -*- lexical-binding: t; coding: utf-8-unix -*- | ||
2 | |||
3 | ;; Customization for consult. | ||
4 | |||
5 | (require 'consult) | ||
6 | |||
7 | ;; "Sensible" functions | ||
8 | (defun acdw-consult/sensible-grep (&optional arg) | ||
9 | "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' | ||
10 | if ripgrep is installed, otherwise `consult-grep'." | ||
11 | (interactive "P") | ||
12 | (cond ((executable-find "rg") | ||
13 | (call-interactively #'consult-ripgrep)) | ||
14 | ((string-equal (vc-backend buffer-file-name) "Git") | ||
15 | (call-interactively #'consult-git-grep)) | ||
16 | (t (call-interactively #'consult-grep)))) | ||
17 | |||
18 | (defun acdw-consult/sensible-find (&optional arg) | ||
19 | "Peform `consult-locate' if locate is installed, otehrwise `consult-find'." | ||
20 | (interactive "P") | ||
21 | (cond ((executable-find "locate") (call-interactively #'consult-locate)) | ||
22 | (t (call-interactively #'consult-find)))) | ||
23 | |||
24 | ;; Orderless Regexp Compiler! -- from Consult Wiki | ||
25 | (defun consult--orderless-regexp-compiler (input type) | ||
26 | (setq input (orderless-pattern-compiler input)) | ||
27 | (cons | ||
28 | (mapcar (lambda (r) (consult--convert-regexp r type)) input) | ||
29 | (lambda (str) (orderless--highlight input str)))) | ||
30 | |||
31 | (defun acdw-consult/complete-in-region (&rest args) | ||
32 | (apply (if vertico-mode | ||
33 | #'consult-completion-in-region | ||
34 | #'completion--in-region) | ||
35 | args)) | ||
36 | |||
37 | (provide 'acdw-consult) | ||