all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: Ruijie Yu <ruijie@netyu.xyz>
Cc: Michael Heerdegen <michael_heerdegen@web.de>, help-gnu-emacs@gnu.org
Subject: Re: command-execute: Wrong type argument: commandp, helm-command-prefix
Date: Fri, 5 May 2023 13:59:15 +0800	[thread overview]
Message-ID: <CAGP6POLBVcs6EMmj5chDaaFxRM2YSEdQ9=0Cbxw0CtCWYcXb_A@mail.gmail.com> (raw)
In-Reply-To: <sdvmt2jfj7z.fsf@netyu.xyz>

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	other threads:[~2023-05-05  5:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05  0:34 command-execute: Wrong type argument: commandp, helm-command-prefix Hongyi Zhao
2023-05-05  1:40 ` Platon Pronko
2023-05-05  2:45   ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-05-05  4:18     ` Hongyi Zhao
2023-05-05  5:04     ` Michael Heerdegen
2023-05-05  5:13       ` Hongyi Zhao
2023-05-05  5:18       ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-05-05  5:59         ` Hongyi Zhao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGP6POLBVcs6EMmj5chDaaFxRM2YSEdQ9=0Cbxw0CtCWYcXb_A@mail.gmail.com' \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=ruijie@netyu.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.