From a2657993bad828af6743c68931a0e848bfcdec53 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 21 Nov 2021 23:57:41 -0600 Subject: I DECLARE BANKRUPTCY ... 8 Didn't think to do this till pretty .. written, so here we are. --- lisp/+consult.el | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lisp/+consult.el (limited to 'lisp/+consult.el') diff --git a/lisp/+consult.el b/lisp/+consult.el new file mode 100644 index 0000000..7b6a20f --- /dev/null +++ b/lisp/+consult.el @@ -0,0 +1,47 @@ +;;; +consult.el --- consult additions -*- lexical-binding: t -*- + +;;; Code: + +(defun +consult-project-root () + "Return either the current project, or the VC root, of current file." + (if (and (functionp 'project-current) + (project-current)) + (car (project-roots (project-current))) + (vc-root-dir))) + +;;; Cribbed functions +;; https://github.com/minad/consult/wiki + +(defun consult--orderless-regexp-compiler (input type) + (setq input (orderless-pattern-compiler input)) + (cons + (mapcar (lambda (r) (consult--convert-regexp r type)) input) + (lambda (str) (orderless--highlight input str)))) + +(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 '+consult) +;;; +consult.el ends here -- cgit 1.4.1-21-gabe81