Make Emacs use ugrep when available

This commit is contained in:
Gerard Vermeulen 2022-08-10 06:49:55 +02:00
parent f717203e8c
commit 9a39a89bc7

View File

@ -1347,6 +1347,45 @@ to {{{kbd(M-s d)}}} and =deadgrep-edit-mode= to {{{kbd(C-c C-w)}}}.
(define-key deadgrep-mode-map (kbd "C-c C-w") #'deadgrep-edit-mode))) (define-key deadgrep-mode-map (kbd "C-c C-w") #'deadgrep-edit-mode)))
#+end_src #+end_src
** [[https://www.genivia.com/get-ugrep.html][Ugrep]]
:PROPERTIES:
:CUSTOM_ID: sec:ugrep
:END:
[[https://www.genivia.com/get-ugrep.html][Ugrep]] is an ultra fast grep with interactive query UI and fuzzy search. The
pages [[https://github.com/Genivia/ugrep#emacs][Using ugrep within Emacs]] and [[https://manueluberti.eu/emacs/2022/08/07/emacs-ugrep/][Ugrep in Emacs]] show how to make Emacs use it
with [[info:emacs#Grep Searching][lgrep]] and [[info:emacs#Xref][xref]]. Listing [[lst:use-ugrep]] shows my implementation of the
suggestions in those pages.
#+caption[Use =ugrep= when available]:
#+caption: Use =ugrep= when available.
#+name: lst:use-ugrep
#+begin_src emacs-lisp
(when (executable-find "ugrep")
(with-eval-after-load 'grep
(custom-set-variables
`(grep-template ,(string-join '("ugrep"
"--color=always"
"--ignore-binary"
"--ignore-case"
"--include=\"<F>\""
"--line-number"
"--null"
"--recursive"
"--regexp=<R>")
" "))))
(with-eval-after-load 'xref
(custom-set-variables
'(xref-search-program-alist
'((grep
. "xargs -0 grep <C> --null -snHE -e <R>")
(ripgrep
. "xargs -0 rg <C> --null -nH --no-heading --no-messages -g '!*/' -e <R>")
(ugrep
. "xargs -0 ugrep <C> --null -ns -e <R>")))
'(xref-search-program 'ugrep))))
#+end_src
* [[info:emacs#Version Control][Version Control (info)]] * [[info:emacs#Version Control][Version Control (info)]]
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sec:version-control :CUSTOM_ID: sec:version-control