From a6fd6508c9f853df9f0a61079f2268cd88e3d5f7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 16 Aug 2021 22:48:29 -0500 Subject: Break out functionality into other files --- lisp/acdw-consult.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lisp/acdw-consult.el (limited to 'lisp/acdw-consult.el') 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 @@ +;;; acdw-consult.el -*- lexical-binding: t; coding: utf-8-unix -*- + +;; Customization for consult. + +(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'." + (interactive "P") + (cond ((executable-find "rg") + (call-interactively #'consult-ripgrep)) + ((string-equal (vc-backend buffer-file-name) "Git") + (call-interactively #'consult-git-grep)) + (t (call-interactively #'consult-grep)))) + +(defun acdw-consult/sensible-find (&optional arg) + "Peform `consult-locate' if locate is installed, otehrwise `consult-find'." + (interactive "P") + (cond ((executable-find "locate") (call-interactively #'consult-locate)) + (t (call-interactively #'consult-find)))) + +;; Orderless Regexp Compiler! -- from 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)))) + +(defun acdw-consult/complete-in-region (&rest args) + (apply (if vertico-mode + #'consult-completion-in-region + #'completion--in-region) + args)) + +(provide 'acdw-consult) -- cgit 1.4.1-21-gabe81