summary refs log tree commit diff stats
path: root/lisp/acdw-consult.el
diff options
context:
space:
mode:
authorCase Duckworth2021-08-16 22:48:29 -0500
committerCase Duckworth2021-08-16 22:48:29 -0500
commita6fd6508c9f853df9f0a61079f2268cd88e3d5f7 (patch)
tree1e3eb323b6f44ed16f09a36e88624289080d7eef /lisp/acdw-consult.el
parentChange work font to Inter (diff)
downloademacs-a6fd6508c9f853df9f0a61079f2268cd88e3d5f7.tar.gz
emacs-a6fd6508c9f853df9f0a61079f2268cd88e3d5f7.zip
Break out functionality into other files
Diffstat (limited to 'lisp/acdw-consult.el')
-rw-r--r--lisp/acdw-consult.el37
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'
10if 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)