0

In the default Emacs menubar (menu-bar.el), a lot of menu items are defined the following way:

[...]
  '(menu-item "Menu item" foo
      :enable (and (menu-bar-menu-frame-live-and-visible-p)
                   (menu-bar-non-minibuffer-window-p))

My question is: what are these :enable conditions for?

EDIT: I'm asking specifically what these two functions are for and why they are used in many menu items. Why would you add this to your menu item?

The documentation of menu-bar-non-minibuffer-window-p says:

Return non-nil if the menu frame's selected window is no minibuffer window. Return nil if the menu frame is dead or its selected window is a minibuffer window.

OK, so the menu item is disabled if the minibuffer is active. But what does it mean that a frame is "dead"?

menu-bar-menu-frame-live-and-visible-p is even more cryptic:

Return non-nil if the menu frame is alive and visible.

What does it mean that a frame is "alive and visible"? (Why would you need to disable a menu item if a frame is not visible, e.g. because it's iconified? Or does this mean something completely different?)

The reason to ask this is in part curiosity (I've been unable to find any further description of these functions) and in part because, say, you want to write a menu for a minor mode or just add something to the menubar: do you need to add them to the :enable keyword? When should they be used?

GrB
  • 207
  • 1
  • 6
  • You're asking multiple questions - about frames, about menu code, etc. Pose just one, specific question per post, please. Each post needs to stand on its own - a specific, single question. – Drew Feb 02 '23 at 02:54
  • Your questions will be good ones, once you specify them clearly and break all of that into separate posts. Please delete this post and do that. Thx. – Drew Feb 02 '23 at 02:55
  • You can find documentation about menus by reading the appopriate section of the Elisp Reference manual: do `C-h i g(elisp)Defining menus`. In particular `:enable` is described in the `Extended Menu Items` subsection. – NickD Feb 02 '23 at 14:21
  • Drew: This is one question, specifically about what `:enable (and (menu-bar-menu-frame-live-and-visible-p) (menu-bar-non-minibuffer-window-p))` does. NickD: I'm not asking about `:enable` in general. – GrB Feb 02 '23 at 20:55

0 Answers0