refactor(lib): use ripgrep instead of git grep

Although this is a refactor for normal users of Doom, it is a bugfix for
one (I assume) unsupported configuration: when Doom is not running from
a git checkout. In that case, `doom--help-package-configs` currently
returns Git's error messages. This breaks `doom/help-packages` because
it expects each returned line to contain at least one `:` character, so
it errors out with `Wrong number of arguments: (file line _match &rest),
2`.

Using ripgrep here should be equivalent for normal users as long as they
have not added untracked files not covered by Doom's .gitignore.
This commit is contained in:
Marien Zwart 2024-04-26 15:47:32 +10:00 committed by Henrik Lissner
parent c9df1c5d42
commit e203309e5c

View file

@ -468,14 +468,12 @@ will open with point on that line."
(defun doom--help-package-configs (package)
(let ((default-directory doom-emacs-dir))
;; TODO Use ripgrep instead
(split-string
(cdr (doom-call-process
"git" "grep" "--no-break" "--no-heading" "--line-number"
(format "%s %s\\($\\| \\)"
"\\(^;;;###package\\|(after!\\|(use-package!\\)"
package)
":(exclude)*.org"))
"rg" "--no-heading" "--line-number" "--iglob" "!*.org"
(format "%s %s($| )"
"(^;;;###package|\\(after!|\\(use-package!)"
package)))
"\n" t)))
(defvar doom--help-packages-list nil)