Subject: Re: bug#68979: Outline mode menu

From: Juri Linkov <[email-masked]>
Date: Fri, 09 Feb 2024 09:12:58 +0200

> While adding new commands ‘outline-cycle’ and ‘outline-cycle-buffer’
> to the outline mode menu, I noticed a strange menu definition.
>
> It looks like "Hide", "Show" and "Headings" were intended to be a submenu,
> but due to the broken menus these titles are not used.
>
>     (define-key map [hide] (cons "Hide" (make-sparse-keymap "Hide")))
>     (define-key map [hide outline-hide-other]
>
>     (define-key map [show] (cons "Show" (make-sparse-keymap "Show")))
>     (define-key map [show outline-show-subtree]
>
>     (define-key map [headings] (cons "Headings" (make-sparse-keymap "Headings")))
>     (define-key map [headings demote-subtree]
>
> Probably this should be transformed to 'easy-menu-define'.

Actually this implementation is intentional as the comments explain.
So there is nothing to do here.

Also I failed to add new commands ‘outline-cycle’ and ‘outline-cycle-buffer’
because they equally fit into both submenus "Show" and "Hide".

So this request could be closed with the following patch that adds the
menu item for outline-minor-mode to make it more prominent as discussed
in bug#68824.

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 47c6a8f0613..5b290899ff5 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1353,6 +1353,15 @@ menu-bar-showhide-menu
                                   (frame-visible-p
                                    (symbol-value 'speedbar-frame))))))
 
+    (bindings--define-key menu [showhide-outline-minor-mode]
+      '(menu-item "Outlines" outline-minor-mode
+                  :help "Turn outline-minor-mode on/off"
+                  :visible (seq-some #'local-variable-p
+                                     '(outline-search-function
+                                       outline-regexp outline-level))
+                  :button (:toggle . (and (boundp 'outline-minor-mode)
+                                          outline-minor-mode))))
+
     (bindings--define-key menu [showhide-tab-line-mode]
       '(menu-item "Window Tab Line" global-tab-line-mode
                   :help "Turn window-local tab-lines on/off"