Subject: bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, not files)

From: Juri Linkov <[email-masked]>
Date: Thu, 15 Dec 2022 20:28:31 +0200

> Hmm... taking a second look at the `mouse.el` file, I think the problem
> is rather than the menu-item has an nominal/default/static binding of
> `ignore`.  So I guess the `:filter` isn't run to try and look for
> `ignore` in the dynamically-generated map but instead it's run later
> (when `where-is-internal` checks that the binding it found is real).
>
> So maybe another way to avoid running the filter is with the
> patch below.
>
> diff --git a/lisp/mouse.el b/lisp/mouse.el
> index 5c645a4b895..9e902ca25e0 100644
> --- a/lisp/mouse.el
> +++ b/lisp/mouse.el
> @@ -513,7 +513,7 @@ context-menu-ffap
>    menu)
>  
>  (defvar context-menu-entry
> -  `(menu-item ,(purecopy "Context Menu") ignore
> +  `(menu-item ,(purecopy "Context Menu") ,(make-sparse-keymap)
>                :filter (lambda (_) (context-menu-map)))
>    "Menu item that creates the context menu and can be bound to a mouse key.")

`where-is-internal(ignore)` raises its ugly head again:

0. emacs -Q
1. M-x TAB

Debugger entered--Lisp error: (void-function cl--set-substring)
  cl--set-substring(#("*scratch* x" 0 9 ...
  tab-bar-auto-width(((sep-1 menu-item " " ignore) (current-tab menu-item #("*scratch* x" 0 9 ...
  tab-bar-make-keymap-1()
  tab-bar-make-keymap(ignore)
  where-is-internal(ignore nil t)
  read-extended-command--affixation((#("2C-associate-buffer" ...
  #f(compiled-function (window) ...
  window--display-buffer(#<buffer *Completions*> ...
  display-buffer-at-bottom(#<buffer *Completions*> ...
  display-buffer(#<buffer *Completions*> ...
  temp-buffer-window-show(#<buffer *Completions*> ...
  minibuffer-completion-help(5 5)
  completion--do-completion(5 5)
  completion--in-region-1(5 5)
  completion--in-region(5 5 #f(compiled-function (string pred action) ..
  completion-in-region(5 5 #f(compiled-function (string pred action) ...
  minibuffer-complete()
  funcall-interactively(minibuffer-complete)
  call-interactively(minibuffer-complete nil nil)
  command-execute(minibuffer-complete)
  completing-read-default("M-x " ...
  completing-read("M-x " ...
  read-extended-command-1("M-x " nil)
  read-extended-command()
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

But using `make-sparse-keymap` fixes it again:

```
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 1baa857e9e9..f040bc9786d 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -416,7 +416,7 @@ tab-bar-map
   "S-<wheel-right>" #'tab-bar-move-tab)
 
 (global-set-key [tab-bar]
-                `(menu-item ,(purecopy "tab bar") ignore
+                `(menu-item ,(purecopy "tab bar") ,(make-sparse-keymap)
                             :filter tab-bar-make-keymap))
```

Not sure if this trick should be documented somewhere.