I want to replace helm-projectile-grep with helm-projectile-ag without using default binding (C-c p s s).

For example if I use helm-projectile-switch-project (C-c p p), then in the helm window I press C-s, then it will invoke helm-projectile-grep, but I want to use helm-projectile-ag instead because it's faster. I don't know what other search action will invoke helm-projectile-grep, but whenever I call the function, I want it to call helm-projectile-ag instead. Is it possible, how can I map it in my .emacs?

1 Answer 1


Maybe you can try to redefine helm-projectile-grep to meet your need. In order to avoid confusion, use Advising instead of a plain defun here:

(define-advice helm-projectile-grep (:override (&optional dir) ag)
  (helm-do-ag (or dir (projectile-project-root))))

The define-advice macro was added to Emacs recently, if you don't have it, then use advice-add. Since Emacs can advice a function without know it, you can put this anywhere in your Emacs initialization file.

  • advice seems nice, never heard of it before. Thanks!
    – Ryan
    Commented Mar 24, 2016 at 10:25
  • If you're only after C-c p p you can also change it's behaviour with (helm-delete-action-from-source "Grep in projects C-s'" helm-source-projectile-projects)` and (helm-add-action-to-source "Grep in projects C-s'" 'helm-do-ag helm-source-projectile-projects 4)` Commented Mar 24, 2016 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.