all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 9923@debbugs.gnu.org, Drew Adams <drew.adams@oracle.com>
Subject: bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, not files)
Date: Thu, 26 Aug 2021 13:44:24 -0400	[thread overview]
Message-ID: <jwveeagw265.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87bl5k2ug1.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 26 Aug 2021 15:42:54 +0200")

Lars Ingebrigtsen [2021-08-26 15:42:54] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> So IIRC `where-is` instead uses the "unfiltered" binding.  So you can
>> often get what you want by being careful about the BINDING you put into
>> `(menu-item "foo" BINDING :filter ...).
>
> Hm...  but in this case, the filter returns all the items:
>
>     (easy-menu-add-item
>      (recentf-menu-bar) recentf-menu-path
>      (list recentf-menu-title :filter 'recentf-make-menu-items)
>      recentf-menu-before)))

I think the problem is that it's not the same filter: there's the
`:filter` above which is part of the easymenu syntax and there the
`:filter` in the `menu-item` syntax.

Easymenu does indeed use the menu-item-:filter to implement the
easymenu-:filter but IIRC easymenu uses a menu item of the form

    (menu-item TITLE MENU :filter ...)

where MENU is the actual menu in its original easymenu-syntax form (aka
XEmacs syntax), and it's converted to the keymap-syntax by the :filter.

That would explain why `where-is` can't find any commands in MENU since
`where-is` expects it to use a keymap-syntax rather than an easymenu-syntax.

The relevant code is in `easy-menu-create-menu`:

        (pcase keyword
          (:filter
           (setq filter (lambda (menu)
                          (easy-menu-filter-return (funcall arg menu)
                                                   menu-name))))

as well as:

                     ;; The filter expects the menu in its XEmacs form and the
                     ;; pre-filter form will only be passed to the filter
                     ;; anyway, so we'd better not convert it at all (it will
                     ;; be converted on the fly by easy-menu-filter-return).
                     menu-items
                   (append menu (mapcar #'easy-menu-convert-item menu-items))))

So maybe the comment is wrong (I can't vouch for the guy who wrote it
anyway), and we should put the pre-converted menu in there, and then the
filter function should simply ignore its `menu` argument and use the
`menu-items` instead (or something like that).

Such a change could break something somewhere, tho: AFAICT currently,
just like the menu-item-:filter, the easymenu-:filter doesn't have to be
accompanied with a "menu" in proper syntax but it is required only to
return a menu in proper syntax, so the format of `menu-items` is
actually private to the :filter (tho in practice it's usually a valid
menu).


        Stefan






  reply	other threads:[~2021-08-26 17:44 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-31 20:26 bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, not files) Drew Adams
2011-11-01 16:05 ` Stefan Monnier
2012-09-17  0:25   ` Drew Adams
2021-08-25 12:18   ` Lars Ingebrigtsen
2021-08-25 14:49     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-26 13:42       ` Lars Ingebrigtsen
2021-08-26 17:44         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-08-29 16:48         ` Juri Linkov
2021-08-29 18:46           ` Lars Ingebrigtsen
2021-08-30  7:33             ` Juri Linkov
2021-08-31  0:03               ` Lars Ingebrigtsen
2021-08-31  6:41                 ` Juri Linkov
2021-08-31  8:36                   ` Lars Ingebrigtsen
2021-08-31 18:44                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-30  6:55                       ` Juri Linkov
2021-09-30 12:43                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-03 17:54                           ` Juri Linkov
2021-10-03 18:36                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-03 18:53                               ` Juri Linkov
2021-10-03 19:26                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-05 18:04           ` Juri Linkov
2021-12-05 20:48             ` Lars Ingebrigtsen
2021-12-05 23:13             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-06  9:28               ` Juri Linkov
2021-12-06 13:50                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-06 17:24                   ` Juri Linkov
2021-12-06 19:01                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-08 20:32                       ` Juri Linkov
2022-12-15 18:28                   ` Juri Linkov
2022-12-15 18:45                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 18:51                       ` Juri Linkov

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=jwveeagw265.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=9923@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /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.