Commit 0fcfa974 authored by Xue Fuqiao's avatar Xue Fuqiao
Browse files

Document `define-alternatives'.

* doc/lispref/elisp.texi (Top):
* doc/lispref/commands.texi (Generic Commands):
(Defining Commands): Document `define-alternatives'.

* etc/NEWS: Related edit.  Unrelated copyedit.
parent 3e557f59
2014-02-28 Xue Fuqiao <xfq@gnu.org>
* elisp.texi (Top):
* commands.texi (Generic Commands):
(Defining Commands): Document `define-alternatives'.
2014-02-27 Xue Fuqiao <xfq@gnu.org>
* windows.texi (Window Sizes): Document `window-size'.
......
......@@ -134,6 +134,7 @@ from Lisp.
* Interactive Codes:: The standard letter-codes for reading arguments
in various ways.
* Interactive Examples:: Examples of how to read interactive arguments.
* Generic Commands:: Select among command alternatives.
@end menu
@node Using Interactive
......@@ -575,6 +576,39 @@ Put them into three windows, selecting the last one."
@end group
@end example
@node Generic Commands
@subsection Select among Command Alternatives
@cindex generic commands
@cindex alternatives, defining
The macro @code{define-alternatives} can be used to define
@dfn{generic commands}. Generic commands are interactive functions
whose implementation can be selected among several alternatives, as a
matter of user preference.
@defmac define-alternatives command &rest customizations
Define the new command `COMMAND'.
The argument `COMMAND' should be a symbol.
When a user runs @kbd{M-x COMMAND @key{RET}} for the first time, Emacs
will prompt for which alternative to use and record the selected
command as a custom variable.
Running @kbd{C-u M-x COMMAND @key{RET}} prompts again for an
alternative and overwrites the previous choice.
The variable @code{COMMAND-alternatives} contains an alist
(@pxref{Association Lists}) with alternative implementations of
`COMMAND'. @code{define-alternatives} does not have any effect until
this variable is set.
If @var{customizations} is non-@var{nil}, it should be composed of
alternating @code{defcustom} keywords and values to add to the
declaration of @code{COMMAND-alternatives} (typically :group and
:version).
@end defmac
@node Interactive Call
@section Interactive Call
@cindex interactive call
......
......@@ -746,6 +746,8 @@ Defining Commands
* Interactive Codes:: The standard letter-codes for reading arguments
in various ways.
* Interactive Examples:: Examples of how to read interactive arguments.
* Generic Commands:: Select among command alternatives.
Input Events
......
......@@ -730,7 +730,7 @@ are lined up to the first one.
+++
** Octave mode
*** Font locking for texinfo comments and new keywords.
*** Font locking for Texinfo comments and new keywords.
*** Completion in Octave file buffers.
......@@ -1155,6 +1155,7 @@ treated as regexps rather than literal strings.
+++
** New functions `special-form-p' and `macrop'.
+++
** New macro `define-alternatives' can be used to define generic commands.
Generic commands are interactive functions whose implementation can be
selected among several alternatives, as a matter of user preference.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment