How do I make the entry in the mode-line popup a minor mode menu when clicked?
For reference see this discussion https://github.com/flycheck/flycheck/issues/365#issuecomment-38386558
How do I make the entry in the mode-line popup a minor mode menu when clicked?
For reference see this discussion https://github.com/flycheck/flycheck/issues/365#issuecomment-38386558
It seems that the menu displayed on clicking the mode-line
entry for a mode is the same menu that is displayed when one clicks on the mode's entry in the menu-bar, provided that the mode defines a top level menu entry. The simplest way would be define a top level menu like so
(easy-menu-define flycheck-menu flycheck-mode-map "Flycheck menu"
'("Flycheck"
["Check current buffer" flycheck-buffer t]
["Clear errors in buffer" flycheck-clear t]
["Compile current buffer" flycheck-compile t]
"---"
["Go to next error" flycheck-next-error t]
["Go to previous error" flycheck-previous-error t]
["Show all errors" flycheck-list-errors t]
["Google messages at point" flycheck-google-messages t]
"---"
["Select syntax checker" flycheck-select-checker t]
"---"
["Describe syntax checker" flycheck-describe-checker t]
["Read the Flycheck manual" flycheck-info t]))
This might not be a solution if you do not want to introduce another menu-bar item. Looking at the function minor-mode-menu-from-indicator
in mouse.el
it seems that it looks up for keybindings starting with [menu-bar]
for getting the mode-line menu, that might also be interesting for you.
Note that you can supply any valid mode-line construct as the STRING
/ lighter value for a given mode's VARIABLE
in minor-mode-alist
.
So although this value is commonly just the name of the mode (or some appropriate abbreviation thereof), you can do more elaborate things such as including set text properties -- which can include a local-map
property to specify a keymap for mouse clicks (see C-hig (elisp) Properties in Mode
RET).
You might look at M-x find-variable
RET mode-line-modes
RET for an example (n.b. IIRC this variable is only in Emacs 24, where the complexity of the mode-line-format
variable was broken out into independent sub-variables, to make the overall structure easier to understand/modify).
See C-hig (elisp) Mode Line Format
RET for the full documentation.