diff options
| author | Richard M. Stallman | 2004-10-27 14:59:47 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-10-27 14:59:47 +0000 |
| commit | dff3f9e1b8fbf5d1c01304d3d8b778723f669714 (patch) | |
| tree | 8955a2c79f2cb8d295a4620fe9db74b9f7ba5fba | |
| parent | f91f2dcc78bde3379c6f8152369a7d6858353b5e (diff) | |
| download | emacs-dff3f9e1b8fbf5d1c01304d3d8b778723f669714.tar.gz emacs-dff3f9e1b8fbf5d1c01304d3d8b778723f669714.zip | |
(Interactive Codes): `N' uses numeric prefix, not raw. Clarify `n'.
(Interactive Call): Rewrite interactive-p, focusing on when and how to use it.
(Misc Events): Clarify previous change.
| -rw-r--r-- | lispref/commands.texi | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/lispref/commands.texi b/lispref/commands.texi index cb772ff6eb5..f1f94e11838 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi | |||
| @@ -382,15 +382,14 @@ method, and returned as a string (@pxref{Input Methods,,, emacs, The GNU | |||
| 382 | Emacs Manual}). Prompt. | 382 | Emacs Manual}). Prompt. |
| 383 | 383 | ||
| 384 | @item n | 384 | @item n |
| 385 | A number read with the minibuffer. If the input is not a number, the | 385 | A number, read with the minibuffer. If the input is not a number, the |
| 386 | user is asked to try again. The prefix argument, if any, is not used. | 386 | user has to try again. @samp{n} never uses the prefix argument. |
| 387 | Prompt. | 387 | Prompt. |
| 388 | 388 | ||
| 389 | @item N | 389 | @item N |
| 390 | @cindex raw prefix argument usage | 390 | The numeric prefix argument; but if there is no prefix argument, read |
| 391 | The numeric prefix argument; but if there is no prefix argument, read a | 391 | a number as with @kbd{n}. The value is always a number. @xref{Prefix |
| 392 | number as with @kbd{n}. Requires a number. @xref{Prefix Command | 392 | Command Arguments}. Prompt. |
| 393 | Arguments}. Prompt. | ||
| 394 | 393 | ||
| 395 | @item p | 394 | @item p |
| 396 | @cindex numeric prefix argument usage | 395 | @cindex numeric prefix argument usage |
| @@ -398,6 +397,7 @@ The numeric prefix argument. (Note that this @samp{p} is lower case.) | |||
| 398 | No I/O. | 397 | No I/O. |
| 399 | 398 | ||
| 400 | @item P | 399 | @item P |
| 400 | @cindex raw prefix argument usage | ||
| 401 | The raw prefix argument. (Note that this @samp{P} is upper case.) No | 401 | The raw prefix argument. (Note that this @samp{P} is upper case.) No |
| 402 | I/O. | 402 | I/O. |
| 403 | 403 | ||
| @@ -613,25 +613,23 @@ part of the prompt. | |||
| 613 | @end deffn | 613 | @end deffn |
| 614 | 614 | ||
| 615 | @defun interactive-p | 615 | @defun interactive-p |
| 616 | This function returns @code{t} if the containing function (the one whose | 616 | This function returns @code{t} if the containing function (the one |
| 617 | code includes the call to @code{interactive-p}) was called | 617 | whose code includes the call to @code{interactive-p}) was called in |
| 618 | interactively, with the function @code{call-interactively}. (It makes | 618 | direct response to user input. This means that it was called with the |
| 619 | no difference whether @code{call-interactively} was called from Lisp or | 619 | function @code{call-interactively}, and that a keyboard macro is |
| 620 | directly from the editor command loop.) If the containing function was | 620 | not running. |
| 621 | called by Lisp evaluation (or with @code{apply} or @code{funcall}), then | 621 | |
| 622 | it was not called interactively. | 622 | If the containing function was called by Lisp evaluation (or with |
| 623 | @code{apply} or @code{funcall}), then it was not called interactively. | ||
| 623 | @end defun | 624 | @end defun |
| 624 | 625 | ||
| 625 | The most common use of @code{interactive-p} is for deciding whether to | 626 | The most common use of @code{interactive-p} is for deciding whether |
| 626 | print an informative message. As a special exception, | 627 | to give the user additional visual feedback (such as by printing an |
| 627 | @code{interactive-p} returns @code{nil} whenever a keyboard macro is | 628 | informative message). For example: |
| 628 | being run. This is to suppress the informative messages and speed | ||
| 629 | execution of the macro. | ||
| 630 | |||
| 631 | For example: | ||
| 632 | 629 | ||
| 633 | @example | 630 | @example |
| 634 | @group | 631 | @group |
| 632 | ;; @r{Here's the usual way to use @code{interactive-p}.} | ||
| 635 | (defun foo () | 633 | (defun foo () |
| 636 | (interactive) | 634 | (interactive) |
| 637 | (when (interactive-p) | 635 | (when (interactive-p) |
| @@ -640,6 +638,7 @@ execution of the macro. | |||
| 640 | @end group | 638 | @end group |
| 641 | 639 | ||
| 642 | @group | 640 | @group |
| 641 | ;; @r{This function is just to illustrate the behavior.} | ||
| 643 | (defun bar () | 642 | (defun bar () |
| 644 | (interactive) | 643 | (interactive) |
| 645 | (setq foobar (list (foo) (interactive-p)))) | 644 | (setq foobar (list (foo) (interactive-p)))) |
| @@ -653,7 +652,7 @@ execution of the macro. | |||
| 653 | 652 | ||
| 654 | @group | 653 | @group |
| 655 | ;; @r{Type @kbd{M-x bar}.} | 654 | ;; @r{Type @kbd{M-x bar}.} |
| 656 | ;; @r{This does not print anything.} | 655 | ;; @r{This does not display a message.} |
| 657 | @end group | 656 | @end group |
| 658 | 657 | ||
| 659 | @group | 658 | @group |
| @@ -662,10 +661,11 @@ foobar | |||
| 662 | @end group | 661 | @end group |
| 663 | @end example | 662 | @end example |
| 664 | 663 | ||
| 665 | The other way to do this sort of job is to make the command take an | 664 | If you want to test @emph{only} whether the function was called |
| 666 | argument @code{print-message} which should be non-@code{nil} in an | 665 | using @code{call-interactively}, add an optional argument |
| 667 | interactive call, and use the @code{interactive} spec to make sure it is | 666 | @code{print-message} which should be non-@code{nil} in an interactive |
| 668 | non-@code{nil}. Here's how: | 667 | call, and use the @code{interactive} spec to make sure it is |
| 668 | non-@code{nil}. Here's an example: | ||
| 669 | 669 | ||
| 670 | @example | 670 | @example |
| 671 | (defun foo (&optional print-message) | 671 | (defun foo (&optional print-message) |
| @@ -675,10 +675,9 @@ non-@code{nil}. Here's how: | |||
| 675 | @end example | 675 | @end example |
| 676 | 676 | ||
| 677 | @noindent | 677 | @noindent |
| 678 | Defined in this way, the function does display the message when | 678 | Defined in this way, the function does display the message when called |
| 679 | called from a keyboard macro. | 679 | from a keyboard macro. We use @code{"p"} because the numeric prefix |
| 680 | 680 | argument is never @code{nil}. | |
| 681 | The numeric prefix argument, provided by @samp{p}, is never @code{nil}. | ||
| 682 | 681 | ||
| 683 | @node Command Loop Info | 682 | @node Command Loop Info |
| 684 | @comment node-name, next, previous, up | 683 | @comment node-name, next, previous, up |
| @@ -1513,16 +1512,17 @@ frame has already been made visible, Emacs has no work to do. | |||
| 1513 | @cindex @code{wheel-down} event | 1512 | @cindex @code{wheel-down} event |
| 1514 | @item (wheel-up @var{position}) | 1513 | @item (wheel-up @var{position}) |
| 1515 | @item (wheel-down @var{position}) | 1514 | @item (wheel-down @var{position}) |
| 1516 | This kind of event is generated by moving a wheel on a mouse. Its | 1515 | These kinds of event are generated by moving a mouse wheel. Their |
| 1517 | effect is typically a kind of scroll or zoom. | 1516 | usual meaning is a kind of scroll or zoom. |
| 1518 | 1517 | ||
| 1519 | The element @var{position} is a list describing the position of the | 1518 | The element @var{position} is a list describing the position of the |
| 1520 | event, in the same format as used in a mouse-click event. | 1519 | event, in the same format as used in a mouse-click event. |
| 1521 | 1520 | ||
| 1522 | This kind of event is generated only on some kinds of systems. On | 1521 | This kind of event is generated only on some kinds of systems. On some |
| 1523 | other systems, mouse-4 and mouse-5 may be used instead. For portable | 1522 | systems, @code{mouse-4} and @code{mouse-5} are used instead. For |
| 1524 | code, the variables @code{mouse-wheel-up-event} and | 1523 | portable code, use the variables @code{mouse-wheel-up-event} and |
| 1525 | @code{mouse-wheel-down-event} defined in @file{mwheel.el} can be used. | 1524 | @code{mouse-wheel-down-event} defined in @file{mwheel.el} to determine |
| 1525 | what event types to expect for the mouse wheel. | ||
| 1526 | 1526 | ||
| 1527 | @cindex @code{drag-n-drop} event | 1527 | @cindex @code{drag-n-drop} event |
| 1528 | @item (drag-n-drop @var{position} @var{files}) | 1528 | @item (drag-n-drop @var{position} @var{files}) |