From fd3d5fc55f5e537bd4da19ada52486eb70e6bf11 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 4 Sep 2021 23:57:04 -0500 Subject: Mostly keywording stuff I messed up my commits here... bah --- lisp/acdw-consult.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lisp') 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 @@ (require 'consult) -;; "Sensible" functions (defun acdw-consult/sensible-grep (&optional arg) "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' if ripgrep is installed, otherwise `consult-grep'." @@ -43,4 +42,29 @@ if ripgrep is installed, otherwise `consult-grep'." #'completion--in-region) args)) +(defmacro consult-history-to-modes (map-hook-alist) + (let (defuns) + (dolist (map-hook map-hook-alist) + (let ((map-name (symbol-name (car map-hook))) + (key-defs `(progn (define-key + ,(car map-hook) + (kbd "M-r") + (function consult-history)) + (define-key ,(car map-hook) + (kbd "M-s") nil)))) + (push (if (cdr map-hook) + `(add-hook ',(cdr map-hook) + (defun + ,(intern (concat map-name + "@consult-history-bind")) + nil + ,(concat + "Bind `consult-history' to M-r in " + map-name ".\n" + "Defined by `consult-history-to-modes'.") + ,key-defs)) + key-defs) + defuns))) + `(progn ,@ (nreverse defuns)))) + (provide 'acdw-consult) -- cgit 1.4.1-21-gabe81