I love helm-ag and I was thinking about creating my own commands which would do helm-ag with a pre-defined query, for example one that would search the project for "TODO" to find all of my TODO markers. This is something that, for example, helm-swoop supports.
Unfortunately I didn't see a way to do this. Perhaps if helm-do-ag took another optional parameter specifying this? I would even be content with hacking around this by creating a local let-binding around the call to helm-do-ag, but there's no variable that's being read for me to do that.
I do notice that helm-do-ag--helm specifies an :input, but there's no obvious way I can see to hack that to make it pick up my own query.
I don't know if this is the best way to do this, but I made these changes on my end:
With this, I was able to implement this command which launches a helm-ag session to search for various markers like TODO, FIXME, etc. If there's a better way to do this I'd love to know:
(defun my-search-todo ()
"Search for any TODO markers as specified in hl-todo-keyword-faces.
Note that this uses the word boundary \\b to avoid matching these
within other words, but this means that non-word keywords such as
???, which is in the list by default, will not be matched."
(interactive)
(require 'projectile)
(let* ((grouped (funcall #'regexp-opt (--map (car it) hl-todo-keyword-faces)))
(unescaped (s-replace-all '(("\\(" . "(") ("\\)" . ")") ("\\|" . "|"))
grouped))
(bounded (concat "\\b" unescaped "\\b"))
(helm-follow-mode-persistent t))
(helm-do-ag (projectile-project-root) nil bounded)))
I love helm-ag and I was thinking about creating my own commands which would do helm-ag with a pre-defined query, for example one that would search the project for "TODO" to find all of my TODO markers. This is something that, for example, helm-swoop supports.
Unfortunately I didn't see a way to do this. Perhaps if
helm-do-ag
took another optional parameter specifying this? I would even be content with hacking around this by creating a local let-binding around the call tohelm-do-ag
, but there's no variable that's being read for me to do that.I do notice that
helm-do-ag--helm
specifies an:input
, but there's no obvious way I can see to hack that to make it pick up my own query.I don't know if this is the best way to do this, but I made these changes on my end:
Would you be open to facilitating this?
With this, I was able to implement this command which launches a helm-ag session to search for various markers like TODO, FIXME, etc. If there's a better way to do this I'd love to know: