Extending Helm with a volatile source

128 views
Skip to first unread message

Bozhidar Batsov

unread,
Oct 17, 2012, 5:12:19 AM10/17/12
to emacs...@googlegroups.com
Hi, guys,

A while back I wrote a small helm plugin for projectile (https://github.com/bbatsov/projectile/blob/master/helm-projectile.el)

The essence of the code would be that:

(defvar helm-c-source-projectile-files-list
  `((name . "Projectile files list")
    ;; Needed for filenames with capitals letters.
    (disable-shortcuts)
    (candidates . helm-c-projectile-files-list)
    (candidate-number-limit . 15)
    (volatile)
    (keymap . ,helm-generic-files-map)
    (help-message . helm-generic-file-help-message)
    (mode-line . helm-generic-file-mode-line-string)
    (match helm-c-match-on-basename)
    (type . file))
  "Helm source definition")

The candidates need to be recalculated every time and this used to work for a while but after recent changes in helm it stopped working and
I'm constantly getting back as candidates the result of the first invocation of helm-c-projectile-files-list

I guess something was changed with the meaning of (volatile)?

Any help/hints would be greatly appreciated! Thanks in advance!


-- 
Cheers,
Bozhidar

Thierry Volpiatto

unread,
Oct 17, 2012, 9:59:41 AM10/17/12
to emacs...@googlegroups.com
Hi Bozhidar,

Bozhidar Batsov <bozhida...@gmail.com> writes:

> Hi, guys,
>
> A while back I wrote a small helm plugin for projectile (https://github.com/bbatsov/projectile/blob/master/helm-projectile.el)
>
> The essence of the code would be that:
>
> (defvar helm-c-source-projectile-files-list
> `((name . "Projectile files list")
> ;; Needed for filenames with capitals letters.
> (disable-shortcuts);>>>> This is no more needed (have no effect)
> (candidates . helm-c-projectile-files-list)
> (candidate-number-limit . 15)
> (volatile)
> (keymap . ,helm-generic-files-map)
> (help-message . helm-generic-file-help-message)
> (mode-line . helm-generic-file-mode-line-string)
> (match helm-c-match-on-basename);>>>> Try instead (match-strict helm-c-match-on-basename)
> (type . file))
> "Helm source definition")
>
>
>
> The candidates need to be recalculated every time and this used to work for a while but after recent changes in helm it stopped working and
> I'm constantly getting back as candidates the result of the first invocation of helm-c-projectile-files-list
>
> I guess something was changed with the meaning of (volatile)?
No, it is the match attribute.
It has worked somehow in the past because match-plugin was disabled at
this time (probably).

Tell me if still not working (note you will loose the match-plugin
effect with match-strict).

> Any help/hints would be greatly appreciated! Thanks in advance!

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

Bozhidar Batsov

unread,
Oct 17, 2012, 11:17:35 AM10/17/12
to emacs...@googlegroups.com
Hi Thierry,

Thanks for the quick response. Unfortunately the problem is still present even with match-strict. No matter what project I'm in, helm displays the files & buffers of the first project I was in when I invoked the helm-projectile command. What else could it be?

If you're in the mood you might install helm-projectile from MELPA and see the problem first hand.

-- 
Cheers,
Bozhidar

Thierry Volpiatto

unread,
Oct 17, 2012, 12:48:26 PM10/17/12
to emacs...@googlegroups.com
Bozhidar Batsov <bozhida...@gmail.com> writes:

> Hi Thierry,
>
> Thanks for the quick response. Unfortunately the problem is still
> present even with match-strict. No matter what project I'm in, helm
> displays the files & buffers of the first project I was in when I
> invoked the helm-projectile command. What else could it be?
Don't know, I will have a look ASAP.

> If you're in the mood you might install helm-projectile from MELPA and see the problem first hand.
Ok thanks.

Thierry Volpiatto

unread,
Oct 17, 2012, 1:37:27 PM10/17/12
to emacs...@googlegroups.com
Bozhidar Batsov <bozhida...@gmail.com> writes:

> Hi Thierry,
>
> Thanks for the quick response. Unfortunately the problem is still
> present even with match-strict. No matter what project I'm in, helm
> displays the files & buffers of the first project I was in when I
> invoked the helm-projectile command. What else could it be?
>
> If you're in the mood you might install helm-projectile from MELPA and see the problem first hand.

Can you tell me where I find "s" ==> (require 's).

Bozhidar Batsov

unread,
Oct 17, 2012, 1:39:12 PM10/17/12
to emacs...@googlegroups.com
Here it is https://github.com/magnars/s.el (it's a new string manipulation library for Emacs)

-- 
Cheers,
Bozhidar

Thierry Volpiatto

unread,
Oct 17, 2012, 2:24:48 PM10/17/12
to emacs...@googlegroups.com
Bozhidar Batsov <bozhida...@gmail.com> writes:

> Here it is https://github.com/magnars/s.el (it's a new string manipulation library for Emacs)
Ok thanks.
At first look, helm is updating correctly so it is not related to
volatile.
Looks more than a cache somewhere which is not updated according to the
new directory (when changing project) or the new directory itself which
is not changed somewhere.
Otherwise for the buffers source, use match, not match-strict, look at
helm-buffers-list for example.

Bozhidar Batsov

unread,
Oct 17, 2012, 5:13:51 PM10/17/12
to emacs...@googlegroups.com
Hmm, that's very odd. Is Helm changing the current-directory (the calculation of the project-root depends on it) variable somewhere? Caching is certainly not the problem, so I'm totally at loss as to what's going on :-)

-- 
Cheers,
Bozhidar

Thierry Volpiatto

unread,
Oct 17, 2012, 6:28:50 PM10/17/12
to emacs...@googlegroups.com
Bozhidar Batsov <bozh...@batsov.com> writes:

> Hmm, that's very odd. Is Helm changing the current-directory (the
> calculation of the project-root depends on it) variable somewhere?
You mean `default-directory'? AFAIK No, helm don't modify that.

> Caching is certainly not the problem, so I'm totally at loss as to
> what's going on :-)


--

Marian Schubert

unread,
Jan 29, 2013, 4:31:57 PM1/29/13
to emacs...@googlegroups.com
I think this is related to - https://github.com/emacs-helm/helm/issues/188

Helm doesn't update it's default-directory for consecutive runs. So your code runs with default-directory of first Helm run.

--
Marian
Reply all
Reply to author
Forward
0 new messages