help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: command-execute: Wrong type argument: commandp, helm-command-prefix


From: Hongyi Zhao
Subject: Re: command-execute: Wrong type argument: commandp, helm-command-prefix
Date: Fri, 5 May 2023 13:59:15 +0800

On Fri, May 5, 2023 at 1:22 PM Ruijie Yu via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
> > Ruijie Yu via Users list for the GNU Emacs text editor
> > <help-gnu-emacs@gnu.org> writes:
> >
> >>     (autoload #'helm-command-prefix "helm-bibtex" nil t))
> >                                                     ^^^^^
> >
> > Is this expected to work reliably?  AFAIU, the thing to be autoloaded is
> > a keymap, not an interactive function.
> >
> > Michael.
>
> Exactly, hence my recommendation against using :bind for keymap
> prefices.  Note that `helm-command-prefix' isn't even a function, yet
> `use-package' marks it with function quote.
>
> Note that the :bind-keymap expansion does not introduce this confusion.

Please also refer to the document of use-package [1]:

Normally :bind expects that commands are functions that will be
autoloaded from the given package. However, this does not work if one
of those commands is actually a keymap, since keymaps are not
functions, and cannot be autoloaded using Emacs' autoload mechanism.

To handle this case, use-package offers a special, limited variant of
:bind called :bind-keymap. The only difference is that the "commands"
bound to by :bind-keymap must be keymaps defined in the package,
rather than command functions. This is handled behind the scenes by
generating custom code that loads the package containing the keymap,
and then re-executes your keypress after the first load, to
reinterpret that keypress as a prefix key.

For example:

(use-package projectile
  :bind-keymap
  ("C-c p" . projectile-command-map))

[1] https://github.com/jwiegley/use-package#binding-to-keymaps

> --
> Best,
>
>
> RY

Zhao

> [Please note that this mail might go to spam due to some
> misconfiguration in my mail server -- still investigating.]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]