38 lines
1.3 KiB
EmacsLisp
38 lines
1.3 KiB
EmacsLisp
;;; 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)
|