Subject: Re: bug#43308: 28.0.50; Improvements to Edit->Search menu

From: Juri Linkov <[email-masked]>
Date: Tue, 22 Sep 2020 11:04:58 +0300

>> Why no keybindings are shown for nonincremental menu items?
>> They still have keybindings, e.g. nonincremental forward search
>> can be started with 'C-s RET', nonincremental backward search
>> with 'C-r RET', nonincremental regexp search 'C-M-s RET', etc.
>
> I suppose I could add some explicitly, with :keys.
> That makes sense.  Unfortunately, none show up
> automatically.  It would be good to somehow fix that.

How about the following patch?

BTW, why "Search Tagged Files..." and "Continue Tags Search" have
no keybindings?

Another problem is that selecting "Continue Tags Search"
signals the error:

emacs -Q
Select "Edit" -> "Search" -> "Continue Tags Search"

  Lisp error: (wrong-type-argument commandp fileloop-continue)

I think "Continue Tags Search" should be disabled when it has no effect.

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1556ee290f..901855402f 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -346,7 +346,9 @@ menu-bar-search-menu
                                    search-ring)
                               (and (eq menu-bar-last-search-type 'regexp)
                                    regexp-search-ring))
-                  :help "Repeat last search backwards"))
+                  :help "Repeat last search backwards"
+                  :keys "\\[isearch-backward] \\<isearch-mode-map>\\[isearch-exit]\
+ \\<minibuffer-local-isearch-map>\\[exit-minibuffer]"))
     (bindings--define-key menu [repeat-search-fwd]
       '(menu-item "Repeat Forward"
                   nonincremental-repeat-search-forward
@@ -354,26 +356,32 @@ menu-bar-search-menu
                                    search-ring)
                               (and (eq menu-bar-last-search-type 'regexp)
                                    regexp-search-ring))
-                  :help "Repeat last search forward"))
+                  :help "Repeat last search forward"
+                  :keys "\\[isearch-forward] \\<isearch-mode-map>\\[isearch-exit]\
+ \\<minibuffer-local-isearch-map>\\[exit-minibuffer]"))
     (bindings--define-key menu [separator-repeat-search]
       menu-bar-separator)
 
     (bindings--define-key menu [re-search-backward]
       '(menu-item "Regexp Backwards..."
                   nonincremental-re-search-backward
-                  :help "Search backwards for a regular expression"))
+                  :help "Search backwards for a regular expression"
+                  :keys "\\[isearch-backward-regexp] \\<isearch-mode-map>\\[isearch-exit]"))
     (bindings--define-key menu [re-search-forward]
       '(menu-item "Regexp Forward..."
                   nonincremental-re-search-forward
-                  :help "Search forward for a regular expression"))
+                  :help "Search forward for a regular expression"
+                  :keys "\\[isearch-forward-regexp] \\<isearch-mode-map>\\[isearch-exit]"))
 
     (bindings--define-key menu [search-backward]
       '(menu-item "String Backwards..."
                   nonincremental-search-backward
-                  :help "Search backwards for a string"))
+                  :help "Search backwards for a string"
+                  :keys "\\[isearch-backward] \\<isearch-mode-map>\\[isearch-exit]"))
     (bindings--define-key menu [search-forward]
       '(menu-item "String Forward..." nonincremental-search-forward
-                  :help "Search forward for a string"))
+                  :help "Search forward for a string"
+                  :keys "\\[isearch-forward] \\<isearch-mode-map>\\[isearch-exit]"))
     menu))