Helm: How to properly enable helm-follow-mode

Created on 28 May 2014  路  12Comments  路  Source: emacs-helm/helm

I want to enable helm-follow-mode in helm-occur and helm-multi-occur by doing so:

(add-hook 'helm-after-initialize-hook
          #'(lambda () (helm-attrset 'follow 1 helm-source-occur)))
(add-hook 'helm-after-initialize-hook
          #'(lambda () (helm-attrset 'follow 1 helm-source-moccur)))

It works fine in my running Emacs. However, after restarting Emacs, this error occurs:

Wrong type argument: consp, nil

How do I setup properly?

Most helpful comment

Now follow-mode is enabled by default in multi occur so you should not have to add some extra config.

All 12 comments

tuhdo [email protected] writes:

How do I setup properly?

You can either:
1) set `helm-follow-mode-persistent' to non--nil.
Then after running helm-occur/moccur once it will be persistent.
2) Use C-/ (It is not helm-follow-mode though)
3) Use helm-attrset in your init file after loading helm-regexp.
(Use with-eval-after-load)

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

I am closing this, please ask such questions on mailing list.
Thanks.

eval-after-load "helm-regexp" .... doesn't work. I always got the error because the helm-source-occur does not exist. I had to initialize the source and add follow-mode like this:

(helm-occur-init-source)

(helm-attrset 'follow 1 helm-source-occur)
(helm-attrset 'follow 1 helm-source-moccur)

I think when helm-regexp is loaded, it should initialize all sources.

But thanks for your advise.

For anyone else that ends up here, not all of the helm sources have initialization functions. In particular, it can make a lot of sense to turn on follow-mode for helm-source-grep, but helm-source-grep is initialized to nil instead of a dummy source. I ended up going with this to get always-on follow-mode for greps:

(setq helm-source-grep (helm-build-dummy-source "init_grep" :follow 1))
(add-hook 'helm-before-initialize-hook
          (lambda () (helm-attrset 'follow 1 helm-source-grep)))

I imagine the :follow 1 is superfluous, but I'm too worn out after chasing this down to confirm/understand that well enough.

skparkes [email protected] writes:

For anyone else that ends up here, not all of the helm sources have
initialization functions. In particular, it can make a lot of sense to
turn on follow-mode for helm-source-grep, but helm-source-grep is
initialized to nil instead of a dummy source.

It is not the way to do, dummy sources are not for this.

I ended up going with this to get always-on follow-mode for greps:

(setq helm-source-grep (helm-build-dummy-source "init_grep" :follow 1))
(add-hook 'helm-before-initialize-hook
(lambda () (helm-attrset 'follow 1 helm-source-grep)))

This hack would work only for grep, please see:

https://github.com/emacs-helm/helm/wiki/FAQ#why-is-a-customizable-helm-source-nil

For the documentation of helm-follow-mode, yes it is deprecated and
should be fixed.

For the helm grep case, I will commit a change that will allow you to
do only:

(defmethod helm-setup-user-source ((source helm-grep-class))
(set-slot-value source 'follow 1))

Will be ready soon.

Thierry

See also helm-follow-mode-persistent.

Thierry

Thanks for your willingness to help out.

I did read about helm-follow-mode-persistent, but I believe that is for making follow-mode "sticky" between helm sessions. I actually don't want it "sticky", I want every helm-occur and helm-grep session to start with follow-mode enabled (even if it was disabled at the end of the last corresponding helm session).

I'll try to read more about helm-setup-user-source now. My elisp prowess is weak, but I can usually (eventually) follow along.

I personally find follow-mode quite helpful when searching through file/buffer contents, but I did not feel like installing the third party helm-swoop just to get that functionality when it was already in helm core.

Thanks for maintaining a very helpful package.

(with-eval-after-load 'helm-regexp
  (setq helm-source-occur
        (helm-make-source "Occur" 'helm-source-multi-occur
          :follow 1)))

For what it's worth, this no longer works recently.

cl-no-applicable-method: No applicable method: make-instance, helm-source-multi-occur, "Occur", :follow, 1

Jorge Israel Pe帽a notifications@github.com writes:

For what it's worth, this no longer works recently.

cl-no-applicable-method: No applicable method: make-instance, helm-source-multi-occur, "Occur", :follow, 1

Because helm-source-multi-occur doesn't exists anymore, see issue #2146.

--
Thierry

Nice, thanks for letting me know!

Now follow-mode is enabled by default in multi occur so you should not have to add some extra config.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bugcook picture bugcook  路  5Comments

azer picture azer  路  3Comments

radix picture radix  路  7Comments

rsuhada picture rsuhada  路  3Comments

edwintorok picture edwintorok  路  5Comments