Search code examples
emacsemacs-helm

how to prevent helm-swoop from returning symbol at point?


I would like to invoke M-x helm-swoop such that it does NOT return the symbol at point. I find that it always picks up undesired symbols, e.g. when I invoke M-x helm-swoop in org-mode, I get Swoop: \*, and I then have to delete the \* before I can enter my desired search term. How can I do this?


Solution

  • This has been bugging me as well, for exactly the same reason (swoop in an Org-mode buffer picking up heading characters), so this question motivated me to go and look.

    Looking at the source, Helm-swoop calls helm-swoop-pre-input-function to populate the prompt, and by default this is set to a function that returns (thing-at-point 'symbol), which is what causes the problem in headings.

    A quick test with the following in my init file seems to work:

    (setq helm-swoop-pre-input-function
           (lambda () nil))
    

    This could certainly be improved by, for example, keeping the default behaviour in non-Org buffers but as I'm only really using swoop in Org buffers this is good enough for me.