2

I'd like to create two keybindings for helm-do-ag-project-root or helm-project-ag

where one would have (setq helm-ag-insert-at-point nil) and one would have (setq helm-ag-insert-at-point 'symbol)

So that I can selectively use word at-point for search.

Below is my attempt but not working.

 (use-package helm-projectile :ensure t :config (defun my-helm-grep-do-git-grep () (setq helm-ag-insert-at-point nil) (helm-projectile-ag) ) (global-set-key (kbd "C-c g") 'my-helm-grep-do-git-grep) (defun my-helm-grep-do-git-grep-at-point () (setq helm-ag-insert-at-point 'symbol) (helm-projectile-ag) ) (global-set-key (kbd "C-c k") 'my-helm-grep-do-git-grep-at-point) ) 
1
  • See this for an alternative solution which always inserts the symbol, but lets you overtype it if you don't want it: emacs.stackexchange.com/a/53219/2498 Commented Jan 15, 2020 at 16:04

3 Answers 3

1

This worked fine for me when I was using helm-ag:

(defun mu-helm-ag-thing-at-point () "Search the symbol at point with `helm-ag'." (interactive) (let ((helm-ag-insert-at-point 'symbol)) (helm-do-ag-project-root))) 
0

You should make your functions interactive (see here).

You could also try the helm-grep-do-git-grep command, which I think is a lot smarter at solving this issue. For example, it always searches the symbol at point if it finds one, but as soon as you start typing the Helm buffer updates automatically to display the new candidates.

0

In Helm, M-n can be used to select thing at point. In most cases.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.