Improve documentation of context menus

* doc/lispref/modes.texi (Major Mode Conventions): Add conventions
of setting menu-bar menus and context menus for a major mode.
* doc/emacs/frames.texi (Menu Mouse Clicks): Fix description of
context menu functionality.
This commit is contained in:
Eli Zaretskii 2021-08-21 11:49:56 +03:00
parent f658b955cc
commit 72e688eacd
2 changed files with 28 additions and 5 deletions

View file

@ -370,11 +370,18 @@ This menu is for changing the default face within the window's buffer.
@findex context-menu-mode
@vindex context-menu-functions
@kindex Down-mouse-3
Some graphical applications use @kbd{mouse-3} for a mode-specific
menu. If you prefer @kbd{mouse-3} in Emacs to bring up such a context
menu instead of running the @code{mouse-save-then-kill} command,
enable @code{context-menu-mode} and customize the variable
@code{context-menu-functions}.
Many GUI applications use @kbd{mouse-3} to display @dfn{context
menus}: menus that provide access to various pertinent settings and
actions for the location and context of the mouse click. If you
prefer this in Emacs over the default function of @kbd{mouse-3}, which
is bound to the @code{mouse-save-then-kill} command (@pxref{Mouse
Commands}), you can enable the minor mode @code{context-menu-mode}.
Then Emacs will show context menus when you click @kbd{mouse-3}. The
exact contents of these context menus depends on the current major
mode and the buffer contents around the place where you click the
mouse. To customize the contents of the context menu, you can use the
variable @code{context-menu-functions} (@pxref{Major Mode
Conventions,,, elisp, The Emacs Lisp Reference Manual}).
@node Mode Line Mouse
@section Mode Line Mouse Commands

View file

@ -470,6 +470,22 @@ setting up a buffer-local value for the variable
Each face that the mode defines should, if possible, inherit from an
existing Emacs face. @xref{Basic Faces}, and @ref{Faces for Font Lock}.
@item
Consider adding a mode-specific menu to the menu bar. This should
preferably include the most important menu-specific settings and
commands that will allow users discovering the main features quickly
and efficiently.
@item
@cindex context menus, for a major mode
@vindex context-menu-functions
Consider adding mode-specific context menus for the mode, to be used
if and when users activate the @code{context-menu-mode} (@pxref{Menu
Mouse Clicks,,, emacs, The Emacs Manual}). To this end, define a
mode-specific function which builds one or more menus depending on the
location of the @kbd{mouse-3} click in the buffer, and then add that
function to the buffer-local value of @code{context-menu-functions}.
@item
The mode should specify how Imenu should find the definitions or
sections of a buffer, by setting up a buffer-local value for the