]> git.eshelyaron.com Git - emacs.git/commitdiff
Document `define-alternatives'.
authorXue Fuqiao <xfq@gnu.org>
Fri, 28 Feb 2014 01:49:25 +0000 (09:49 +0800)
committerXue Fuqiao <xfq@gnu.org>
Fri, 28 Feb 2014 01:49:25 +0000 (09:49 +0800)
* doc/lispref/elisp.texi (Top):
* doc/lispref/commands.texi (Generic Commands):
(Defining Commands): Document `define-alternatives'.

* etc/NEWS: Related edit.  Unrelated copyedit.

doc/lispref/ChangeLog
doc/lispref/commands.texi
doc/lispref/elisp.texi
etc/NEWS

index f32f88c18aebb6034d9a981d250d6023cf940ff6..650f97375d6122f05df0594080683f48c5e0b679 100644 (file)
@@ -1,3 +1,9 @@
+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'.
index 1df7a856a5d129fa1a38084f9ea55889dec6dfc7..e4494e7538f6e521da7c212cc195121304d9d1e3 100644 (file)
@@ -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
index b512968ff78a646d9108141e6b344c97723493b7..76b985762547aa9a0455aece54af4574db78ca1e 100644 (file)
@@ -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
 
index b9240f2936f45087701aef9d357e090d1ae46e15..d08efc818d2a6f14f520f47ff4422f302711fe20 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.