diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw-consult.el | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lisp/acdw-consult.el b/lisp/acdw-consult.el index 58a2136..daad645 100644 --- a/lisp/acdw-consult.el +++ b/lisp/acdw-consult.el | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | (require 'consult) | 5 | (require 'consult) |
6 | 6 | ||
7 | ;; "Sensible" functions | ||
8 | (defun acdw-consult/sensible-grep (&optional arg) | 7 | (defun acdw-consult/sensible-grep (&optional arg) |
9 | "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' | 8 | "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' |
10 | if ripgrep is installed, otherwise `consult-grep'." | 9 | if ripgrep is installed, otherwise `consult-grep'." |
@@ -43,4 +42,29 @@ if ripgrep is installed, otherwise `consult-grep'." | |||
43 | #'completion--in-region) | 42 | #'completion--in-region) |
44 | args)) | 43 | args)) |
45 | 44 | ||
45 | (defmacro consult-history-to-modes (map-hook-alist) | ||
46 | (let (defuns) | ||
47 | (dolist (map-hook map-hook-alist) | ||
48 | (let ((map-name (symbol-name (car map-hook))) | ||
49 | (key-defs `(progn (define-key | ||
50 | ,(car map-hook) | ||
51 | (kbd "M-r") | ||
52 | (function consult-history)) | ||
53 | (define-key ,(car map-hook) | ||
54 | (kbd "M-s") nil)))) | ||
55 | (push (if (cdr map-hook) | ||
56 | `(add-hook ',(cdr map-hook) | ||
57 | (defun | ||
58 | ,(intern (concat map-name | ||
59 | "@consult-history-bind")) | ||
60 | nil | ||
61 | ,(concat | ||
62 | "Bind `consult-history' to M-r in " | ||
63 | map-name ".\n" | ||
64 | "Defined by `consult-history-to-modes'.") | ||
65 | ,key-defs)) | ||
66 | key-defs) | ||
67 | defuns))) | ||
68 | `(progn ,@ (nreverse defuns)))) | ||
69 | |||
46 | (provide 'acdw-consult) | 70 | (provide 'acdw-consult) |