Last active
November 10, 2025 12:26
-
-
Save jthaman/c4eb411defc98f82cfd85c8c0d4c67e0 to your computer and use it in GitHub Desktop.
Call ripgrep-all in emacs with consult
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; New versions of consult make this dramatically simpler than it used to be. Just one function that you can bind to a key: | |
| ;;;###autoload | |
| (defun consult-ripgrep-all (&optional dir initial) | |
| (interactive "P") | |
| (let ((consult-ripgrep-args "rga --null --line-buffered --color=never --max-columns=1000 --smart-case --no-heading --with-filename --line-number")) | |
| (consult-ripgrep dir initial))) |
Author
same, same.
ty for posting! probably saved me an hour or more 👍
Thanks for sharing this! This still works.
For the PDF page upon selection, you can try this (requires pdf-tools):
(defun pdf-consult-ripgrep-all (&optional dir initial)
(interactive "P")
(let* ((consult-ripgrep-args "rga --null --line-buffered --color=never --max-columns=1000 --smart-case --no-heading --with-filename --line-number")
(result (consult-ripgrep dir initial)))
(when (and result (string-match "\\([^:]+\\.pdf\\).*page \\([0-9]+\\)" result))
(pdf-view-goto-page (string-to-number (match-string 2 result))))))
There's still room for improvement. It does not take you to the page during the preview. I'll leave that for later.
@jthaman Thank you for this.
I noticed that ripgrep by default considers .gitignore. As binary files like pdf are usually part of .gitignore it was not searched by ripgrep-all.
If someone is facing the same issue, then include --no-ignore-vcs flag as one of the args in consult-ripgrep-args to resolve this. But note that there will be performance penalty in big repos.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't have much knowledge of elisp, consult or embark. So I don't have good suggestions. :)