]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/commands.texi
Include interactive-only information in describe-function output
[gnu-emacs] / doc / lispref / commands.texi
index 1df7a856a5d129fa1a38084f9ea55889dec6dfc7..721a485382eb354e5dc149e4853414c7ca05546c 100644 (file)
@@ -122,18 +122,26 @@ function symbol's @code{interactive-form} property.  A non-@code{nil}
 value for this property takes precedence over any @code{interactive}
 form in the function body itself.  This feature is seldom used.
 
+@anchor{The interactive-only property}
 @cindex @code{interactive-only} property
-  Sometimes, a named command is only intended to be called
-interactively, never directly from Lisp.  In that case, give it a
-non-@code{nil} @code{interactive-only} property.  In that case, the
-byte compiler will print a warning message if the command is called
-from Lisp.
+  Sometimes, a function is only intended to be called interactively,
+never directly from Lisp.  In that case, give the function a
+non-@code{nil} @code{interactive-only} property, either directly
+or via @code{declare} (@pxref{Declare Form}).  This causes the
+byte compiler to warn if the command is called from Lisp.  The output
+of @code{describe-function} will include similar information.
+The value of the property can be: a string, which the byte-compiler
+will use directly in its warning (it should end with a period, and not
+start with a capital, e.g. ``use @dots{} instead.''); @code{t}; any
+other symbol, which should be an alternative function to use in Lisp
+code.
 
 @menu
 * Using Interactive::     General rules for @code{interactive}.
 * 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 +583,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
@@ -2437,7 +2478,7 @@ displayed there.  Otherwise @code{read-event} does not move the cursor.
 If @var{seconds} is non-@code{nil}, it should be a number specifying
 the maximum time to wait for input, in seconds.  If no input arrives
 within that time, @code{read-event} stops waiting and returns
-@code{nil}.  A floating-point value for @var{seconds} means to wait
+@code{nil}.  A floating point @var{seconds} means to wait
 for a fractional number of seconds.  Some systems support only a whole
 number of seconds; on these systems, @var{seconds} is rounded down.
 If @var{seconds} is @code{nil}, @code{read-event} waits as long as
@@ -2881,8 +2922,8 @@ time to read text that you display.  The value is @code{t} if
 @code{sit-for} waited the full time with no input arriving
 (@pxref{Event Input Misc}).  Otherwise, the value is @code{nil}.
 
-The argument @var{seconds} need not be an integer.  If it is floating
-point number, @code{sit-for} waits for a fractional number of seconds.
+The argument @var{seconds} need not be an integer.  If it is floating
+point, @code{sit-for} waits for a fractional number of seconds.
 Some systems support only a whole number of seconds; on these systems,
 @var{seconds} is rounded down.
 
@@ -2908,8 +2949,8 @@ This function simply pauses for @var{seconds} seconds without updating
 the display.  It pays no attention to available input.  It returns
 @code{nil}.
 
-The argument @var{seconds} need not be an integer.  If it is floating
-point number, @code{sleep-for} waits for a fractional number of seconds.
+The argument @var{seconds} need not be an integer.  If it is floating
+point, @code{sleep-for} waits for a fractional number of seconds.
 Some systems support only a whole number of seconds; on these systems,
 @var{seconds} is rounded down.