diff options
| author | Xue Fuqiao | 2014-02-28 09:49:25 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2014-02-28 09:49:25 +0800 |
| commit | 0fcfa97418aa7e7fa42887507e25b9bdf150cc66 (patch) | |
| tree | e67dc197846285696d3c4e03a5bd45a770ee1065 | |
| parent | 3e557f5988c5f52dabce3fae470703d693ba6b5a (diff) | |
| download | emacs-0fcfa97418aa7e7fa42887507e25b9bdf150cc66.tar.gz emacs-0fcfa97418aa7e7fa42887507e25b9bdf150cc66.zip | |
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.
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/commands.texi | 34 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 2 | ||||
| -rw-r--r-- | etc/NEWS | 3 |
4 files changed, 44 insertions, 1 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index f32f88c18ae..650f97375d6 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-02-28 Xue Fuqiao <xfq@gnu.org> | ||
| 2 | |||
| 3 | * elisp.texi (Top): | ||
| 4 | * commands.texi (Generic Commands): | ||
| 5 | (Defining Commands): Document `define-alternatives'. | ||
| 6 | |||
| 1 | 2014-02-27 Xue Fuqiao <xfq@gnu.org> | 7 | 2014-02-27 Xue Fuqiao <xfq@gnu.org> |
| 2 | 8 | ||
| 3 | * windows.texi (Window Sizes): Document `window-size'. | 9 | * windows.texi (Window Sizes): Document `window-size'. |
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 1df7a856a5d..e4494e7538f 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi | |||
| @@ -134,6 +134,7 @@ from Lisp. | |||
| 134 | * Interactive Codes:: The standard letter-codes for reading arguments | 134 | * Interactive Codes:: The standard letter-codes for reading arguments |
| 135 | in various ways. | 135 | in various ways. |
| 136 | * Interactive Examples:: Examples of how to read interactive arguments. | 136 | * Interactive Examples:: Examples of how to read interactive arguments. |
| 137 | * Generic Commands:: Select among command alternatives. | ||
| 137 | @end menu | 138 | @end menu |
| 138 | 139 | ||
| 139 | @node Using Interactive | 140 | @node Using Interactive |
| @@ -575,6 +576,39 @@ Put them into three windows, selecting the last one." | |||
| 575 | @end group | 576 | @end group |
| 576 | @end example | 577 | @end example |
| 577 | 578 | ||
| 579 | @node Generic Commands | ||
| 580 | @subsection Select among Command Alternatives | ||
| 581 | @cindex generic commands | ||
| 582 | @cindex alternatives, defining | ||
| 583 | |||
| 584 | The macro @code{define-alternatives} can be used to define | ||
| 585 | @dfn{generic commands}. Generic commands are interactive functions | ||
| 586 | whose implementation can be selected among several alternatives, as a | ||
| 587 | matter of user preference. | ||
| 588 | |||
| 589 | @defmac define-alternatives command &rest customizations | ||
| 590 | Define the new command `COMMAND'. | ||
| 591 | |||
| 592 | The argument `COMMAND' should be a symbol. | ||
| 593 | |||
| 594 | When a user runs @kbd{M-x COMMAND @key{RET}} for the first time, Emacs | ||
| 595 | will prompt for which alternative to use and record the selected | ||
| 596 | command as a custom variable. | ||
| 597 | |||
| 598 | Running @kbd{C-u M-x COMMAND @key{RET}} prompts again for an | ||
| 599 | alternative and overwrites the previous choice. | ||
| 600 | |||
| 601 | The variable @code{COMMAND-alternatives} contains an alist | ||
| 602 | (@pxref{Association Lists}) with alternative implementations of | ||
| 603 | `COMMAND'. @code{define-alternatives} does not have any effect until | ||
| 604 | this variable is set. | ||
| 605 | |||
| 606 | If @var{customizations} is non-@var{nil}, it should be composed of | ||
| 607 | alternating @code{defcustom} keywords and values to add to the | ||
| 608 | declaration of @code{COMMAND-alternatives} (typically :group and | ||
| 609 | :version). | ||
| 610 | @end defmac | ||
| 611 | |||
| 578 | @node Interactive Call | 612 | @node Interactive Call |
| 579 | @section Interactive Call | 613 | @section Interactive Call |
| 580 | @cindex interactive call | 614 | @cindex interactive call |
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index b512968ff78..76b98576254 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -746,6 +746,8 @@ Defining Commands | |||
| 746 | * Interactive Codes:: The standard letter-codes for reading arguments | 746 | * Interactive Codes:: The standard letter-codes for reading arguments |
| 747 | in various ways. | 747 | in various ways. |
| 748 | * Interactive Examples:: Examples of how to read interactive arguments. | 748 | * Interactive Examples:: Examples of how to read interactive arguments. |
| 749 | * Generic Commands:: Select among command alternatives. | ||
| 750 | |||
| 749 | 751 | ||
| 750 | Input Events | 752 | Input Events |
| 751 | 753 | ||
| @@ -730,7 +730,7 @@ are lined up to the first one. | |||
| 730 | +++ | 730 | +++ |
| 731 | ** Octave mode | 731 | ** Octave mode |
| 732 | 732 | ||
| 733 | *** Font locking for texinfo comments and new keywords. | 733 | *** Font locking for Texinfo comments and new keywords. |
| 734 | 734 | ||
| 735 | *** Completion in Octave file buffers. | 735 | *** Completion in Octave file buffers. |
| 736 | 736 | ||
| @@ -1155,6 +1155,7 @@ treated as regexps rather than literal strings. | |||
| 1155 | +++ | 1155 | +++ |
| 1156 | ** New functions `special-form-p' and `macrop'. | 1156 | ** New functions `special-form-p' and `macrop'. |
| 1157 | 1157 | ||
| 1158 | +++ | ||
| 1158 | ** New macro `define-alternatives' can be used to define generic commands. | 1159 | ** New macro `define-alternatives' can be used to define generic commands. |
| 1159 | Generic commands are interactive functions whose implementation can be | 1160 | Generic commands are interactive functions whose implementation can be |
| 1160 | selected among several alternatives, as a matter of user preference. | 1161 | selected among several alternatives, as a matter of user preference. |