From e203309e5cdc178a03c3d843019f0a2a68e7bb57 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Fri, 26 Apr 2024 15:47:32 +1000 Subject: [PATCH] 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. --- lisp/lib/help.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/lib/help.el b/lisp/lib/help.el index 777e337bf..b25962f09 100644 --- a/lisp/lib/help.el +++ b/lisp/lib/help.el @@ -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)