simple function to launch helm-buffer-list with predefined search..my code dosent work :)

35 views
Skip to first unread message

zeltak brisbane

unread,
Apr 9, 2016, 3:06:12 AM4/9/16
to emacs-helm
Hi all

first ill start by saying (and apologize) that i have zero coding skills :)

Having said that i looked at writing a simple function that will launch helm-buffer-list with predefined search (in my case filter only dired buffers). the idea seems straight forward but for some reason i cant get it to work. the helm-buffer-list does come up but without my predefined input (and also off topic ignores the  :full-frame t i give it as well).

This is the code i use:

 (defun helm-dired-buf ()
   "show dired buffers"
   (interactive)
   (helm :sources (helm-buffers-list)
         :full-frame t
         :input "\\*dired"
        ))


anyone have some time to point me in the right direction and see what im doing wrong?

best regards

Z

Thierry Volpiatto

unread,
Apr 9, 2016, 5:58:56 AM4/9/16
to emacs...@googlegroups.com

zeltak brisbane <ikl...@gmail.com> writes:

> This is the code i use:
>
> (defun helm-dired-buf ()
> "show dired buffers"
> (interactive)
> (helm :sources (helm-buffers-list)

`helm-buffers-list` is a command, not a source,
the source you want is `helm-source-buffers-list`.

> :full-frame t
> :input "\\*dired"

No need to escape this, i.e use "*dired", or even better "*dired " to
allow typing directly some more patterns matching your dired buffers.


--
Thierry

zeltak brisbane

unread,
Apr 9, 2016, 10:51:14 AM4/9/16
to emacs-helm
perfect!

thx so much , helm is EPIC :)

best

Z

zeltak brisbane

unread,
Apr 9, 2016, 11:33:41 AM4/9/16
to emacs-helm
actually one last Question thats related :)

within my function is there a way to pre sort the helm buffer?

best

Z

Itai kloog

unread,
Apr 14, 2016, 7:12:50 AM4/14/16
to Michael Heerdegen, zeltak brisbane, emacs-helm
Thanks Michael for your detailed response

i really appreciate it

best

Z

On Wed, Apr 13, 2016 at 6:40 PM, Michael Heerdegen <michael_...@web.de> wrote:
itai kloog  <ikl...@gmail.com> writes:

> I am very new to lisp (I can really code ;-))
>
> I was wondering if you could shouw me in the example function I wrote
> how to integrate the filtered-candidate-transformer command to sort by
> name or date?
>
>  (defun z/helm-buffers-org ()
>    "show dired buffers"
>    (interactive)
>    (helm :sources '(helm-source-buffers-list)
>          :full-frame t
>          :input "*org "
>         ))

`filtered-candidate-transformer' is a source parameter.  Helm sources
are implemented as (eieio) objects.  `helm-make-source' creates a new
instance of some Helm class.  `helm-source-buffers-list' is an instance
of the `helm-source-buffers' class.

We use classes and objects for sources because this way it's very easy
to re-define sources with some attributes different from the default, or
to use multiple similar sources in different contexts.

`helm-make-source' allows you to conveniently override the default
attributes defined by the class, or add additional ones.

So, you have two choices here: either just redefine
`helm-source-buffers-list' to use your new candidate transformer in your
config, or create a new instance of the `helm-source-buffers' class and
use it in your command.

Does that help enough for you to figure out how to do it?


Regards,

Michael.

Thierry Volpiatto

unread,
Apr 15, 2016, 1:55:01 AM4/15/16
to emacs...@googlegroups.com, Michael Heerdegen, zeltak brisbane, emacs-helm

Itai kloog <ikl...@gmail.com> writes:

> `filtered-candidate-transformer' is a source parameter. Helm sources
> are implemented as (eieio) objects. `helm-make-source' creates a new
> instance of some Helm class.

No it create an alist.

> `helm-source-buffers-list' is an instance of the
> `helm-source-buffers' class.

It is not, it is a simple alist like all helm sources.

Class => instance of class => helm-make-source => source (alist).

> We use classes and objects for sources because this way it's very easy
> to re-define sources with some attributes different from the default, or
> to use multiple similar sources in different contexts.
>
> `helm-make-source' allows you to conveniently override the default
> attributes defined by the class, or add additional ones.
>
> So, you have two choices here: either just redefine
> `helm-source-buffers-list' to use your new candidate transformer in your
> config, or create a new instance of the `helm-source-buffers' class and
> use it in your command.

When a class exists and the source is defined at run time, the prefered
way to modify a source is the defmethod `helm-setup-user-source`.
See https://github.com/emacs-helm/helm/wiki/FAQ#why-is-a-customizable-helm-source-nil

--
Thierry

Thierry Volpiatto

unread,
Apr 15, 2016, 7:05:26 AM4/15/16
to Michael Heerdegen, emacs...@googlegroups.com, zeltak brisbane, emacs-helm

Michael Heerdegen <michael_...@web.de> writes:

> The actual object instances are just thrown away, right?

Yes.

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