How to create more specified custom search commands? #1178
-
In my previous post, I have integrated Everything and RGA into consult-locate and consult-ripgrep. The problem is that now these commands are taken, and I can not further specify more search commands. For instance, I want to search only path, not files. I can either type 2025-02-05 update: TODO: not sure how to get (use-package consult
:config
(defcustom consult-everything-args
"es -r"
"Command line arguments for everything, see `consult-everything'.
The default value is \"es -r\", which only works if you place the command line version of Everything (es.exe) in your PATH."
:type 'string)
(defun consult--everything-builder (input)
"Build command line from INPUT."
(pcase-let ((`(,arg . ,opts) (consult--command-split input)))
(unless (string-blank-p arg)
(cons (append (consult--build-args consult-everything-args)
(consult--split-escaped arg) opts)
(cdr (consult--default-regexp-compiler input 'basic t))))))
(defun consult-everything (&optional initial)
"Search with `everything' for files matching input regexp given INITIAL input."
(interactive)
(find-file (consult--find "Everything: " #'consult--everything-builder initial)))
(defun consult-everything-dir (&optional initial)
"Search for directory using Everything."
(interactive)
(let ((consult-everything-args "es -sort date-modified-descending folder:"))
(consult-everything initial)))
(defun consult-everything-local (&optional initial)
"Search for files in the current directory using Everything."
(interactive)
(let ((consult-everything-args "es -path ."))
(consult-everything initial)))
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You could create separate commands wrapping |
Beta Was this translation helpful? Give feedback.
-
Hi @minad , thanks for quick response. Sorry my Elisp skill remain quite primitive. Is there any template for wrapping consul-locate commands and let-bind consult-locate-args? |
Beta Was this translation helpful? Give feedback.
You could create separate commands wrapping
consult-locate
and let-bindconsult-locate-args
around the call toconsult-locate
. Would that work?