Skip to content

helm-grep: run ag from the current project root #2731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions helm-grep.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
(require 'helm)
(require 'helm-help)
(require 'helm-regexp)
(require 'project)

;;; load wgrep proxy if it's available
(require 'wgrep-helm nil t)
Expand Down Expand Up @@ -1848,6 +1849,25 @@ version."
(require 'helm-files)
(helm-grep-ag (expand-file-name default-directory) arg))

;;;###autoload
(defun helm-do-grep-ag-project (arg)
"Preconfigured `helm' for grepping with AG from the current project root.
With prefix arg prompt for type if available with your AG version."
(interactive "P")
(require 'helm-files)
(require 'project)
(helm-aif (project-current)
(let* ((project-type (car it))
(project-root (cond ((equal project-type 'vc)
(car (last it)))
((equal project-type 'projectile)
(cdr it))
(t default-directory)))
(project-root-abs (expand-file-name project-root))
(default-directory project-root-abs))
(helm-grep-ag project-root-abs arg))
(message "Not in any project!")))

;;;###autoload
(defun helm-grep-do-git-grep (arg)
"Preconfigured `helm' for git-grepping `default-directory'.
Expand Down