unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* describe-buffer-bindings and menu-items with :prefix
@ 2020-01-15 14:25 yyoncho
  2020-01-15 17:26 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: yyoncho @ 2020-01-15 14:25 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 829 bytes --]

Hi,

I am trying to setup a set of shortcuts that depend on the current state
and I am trying to do that using menu-item and prefix. Everything is
working fine but I noticed that these bindings are not returned
by describe-buffer-bindings, e. g.

(define-key global-map (kbd "C-c C-l r v") 'visible)
(define-key global-map (kbd "C-c C-l r V") '(menu-item "1" visible-too))
(define-key global-map (kbd "C-c C-l r X") '(menu-item "2" :filter (lambda
(&rest _)

 (lambda ()

 (interactive)

 (message "Called")))))

(describe-buffer-bindings (current-buffer) [3 12 114] t)

Results in:

Global Bindings Starting With C-c C-l r:
key             binding
---             -------

C-c C-l r V     visible-too
C-c C-l r v     visible

Is there a way to force describe-buffer-bindings to return the menu-items
with :prefix?

Thanks,
Ivan

[-- Attachment #2: Type: text/html, Size: 1418 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: describe-buffer-bindings and menu-items with :prefix
  2020-01-15 14:25 describe-buffer-bindings and menu-items with :prefix yyoncho
@ 2020-01-15 17:26 ` Stefan Monnier
  2020-01-15 17:35   ` yyoncho
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2020-01-15 17:26 UTC (permalink / raw)
  To: yyoncho; +Cc: emacs-devel

> (define-key global-map (kbd "C-c C-l r X") '(menu-item "2" :filter (lambda (&rest _)
>                                                                      (lambda ()
>                                                                        (interactive)
>                                                                        (message "Called")))))

This is a broken `menu-item`: the `:filter` above is not treated as
a keyword argument but as "the command".

You should use something like:

    (define-key global-map (kbd "C-c C-l r X")
      `(menu-item "2" ,(lambda () (interactive) (message "Called"))
                  :filter ,(lambda (cmd) cmd)))

[ of course, I assume you'll use a more interesting filter than the
  identity function.  ]


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: describe-buffer-bindings and menu-items with :prefix
  2020-01-15 17:26 ` Stefan Monnier
@ 2020-01-15 17:35   ` yyoncho
  0 siblings, 0 replies; 3+ messages in thread
From: yyoncho @ 2020-01-15 17:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

Thank you, this is what I was looking for.

On Wed, Jan 15, 2020 at 7:26 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > (define-key global-map (kbd "C-c C-l r X") '(menu-item "2" :filter
> (lambda (&rest _)
> >
> (lambda ()
> >
> (interactive)
> >
> (message "Called")))))
>
> This is a broken `menu-item`: the `:filter` above is not treated as
> a keyword argument but as "the command".
>
> You should use something like:
>
>     (define-key global-map (kbd "C-c C-l r X")
>       `(menu-item "2" ,(lambda () (interactive) (message "Called"))
>                   :filter ,(lambda (cmd) cmd)))
>
> [ of course, I assume you'll use a more interesting filter than the
>   identity function.  ]
>
>
>         Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 1500 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-15 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 14:25 describe-buffer-bindings and menu-items with :prefix yyoncho
2020-01-15 17:26 ` Stefan Monnier
2020-01-15 17:35   ` yyoncho

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).