Mercurial > emacs
comparison lispref/commands.texi @ 90043:e24e2e78deda
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-69
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-643
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-649
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-651
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-655
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-656
Update from CVS: lisp/man.el (Man-xref-normal-file): Fix help-echo.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-657
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-658
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-659
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-660
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-661
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-667
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-61
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-68
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 04 Nov 2004 08:55:40 +0000 |
parents | 0fe073a08cef 69ecb96f8494 |
children | cb7f41387eb3 |
comparison
equal
deleted
inserted
replaced
90042:003d95404d71 | 90043:e24e2e78deda |
---|---|
380 Arbitrary text, read in the minibuffer using the current buffer's input | 380 Arbitrary text, read in the minibuffer using the current buffer's input |
381 method, and returned as a string (@pxref{Input Methods,,, emacs, The GNU | 381 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 |
397 The numeric prefix argument. (Note that this @samp{p} is lower case.) | 396 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 |
404 @item r | 404 @item r |
405 @cindex region argument | 405 @cindex region argument |
611 @end group | 611 @end group |
612 @end example | 612 @end example |
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, and that Emacs is not running in batch mode. |
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 @end defun | 623 @code{apply} or @code{funcall}), then it was not called interactively. |
624 | 624 @end defun |
625 The most common use of @code{interactive-p} is for deciding whether to | 625 |
626 print an informative message. As a special exception, | 626 The most common use of @code{interactive-p} is for deciding whether |
627 @code{interactive-p} returns @code{nil} whenever a keyboard macro is | 627 to give the user additional visual feedback (such as by printing an |
628 being run. This is to suppress the informative messages and speed | 628 informative message). For example: |
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) |
638 (message "foo"))) | 636 (message "foo"))) |
639 @result{} foo | 637 @result{} foo |
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)))) |
646 @result{} bar | 645 @result{} bar |
647 @end group | 646 @end group |
651 @print{} foo | 650 @print{} foo |
652 @end group | 651 @end group |
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 |
660 foobar | 659 foobar |
661 @result{} (nil t) | 660 @result{} (nil t) |
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) |
672 (interactive "p") | 672 (interactive "p") |
673 (when print-message | 673 (when print-message |
674 (message "foo"))) | 674 (message "foo"))) |
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}. | 681 |
682 @defun called-interactively-p | |
683 This function returns @code{t} when the calling function was called | |
684 using @code{call-interactively}. | |
685 | |
686 When possible, instead of using this function, you should use the | |
687 method in the example above; that method makes it possible for a | |
688 caller to ``pretend'' that the function was called interactively. | |
689 @end defun | |
682 | 690 |
683 @node Command Loop Info | 691 @node Command Loop Info |
684 @comment node-name, next, previous, up | 692 @comment node-name, next, previous, up |
685 @section Information from the Command Loop | 693 @section Information from the Command Loop |
686 | 694 |
1511 | 1519 |
1512 @cindex @code{wheel-up} event | 1520 @cindex @code{wheel-up} event |
1513 @cindex @code{wheel-down} event | 1521 @cindex @code{wheel-down} event |
1514 @item (wheel-up @var{position}) | 1522 @item (wheel-up @var{position}) |
1515 @item (wheel-down @var{position}) | 1523 @item (wheel-down @var{position}) |
1516 This kind of event is generated by moving a wheel on a mouse. Its | 1524 These kinds of event are generated by moving a mouse wheel. Their |
1517 effect is typically a kind of scroll or zoom. | 1525 usual meaning is a kind of scroll or zoom. |
1518 | 1526 |
1519 The element @var{position} is a list describing the position of the | 1527 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. | 1528 event, in the same format as used in a mouse-click event. |
1521 | 1529 |
1522 This kind of event is generated only on some kinds of systems. On | 1530 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 | 1531 systems, @code{mouse-4} and @code{mouse-5} are used instead. For |
1524 code, the variables @code{mouse-wheel-up-event} and | 1532 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. | 1533 @code{mouse-wheel-down-event} defined in @file{mwheel.el} to determine |
1534 what event types to expect for the mouse wheel. | |
1526 | 1535 |
1527 @cindex @code{drag-n-drop} event | 1536 @cindex @code{drag-n-drop} event |
1528 @item (drag-n-drop @var{position} @var{files}) | 1537 @item (drag-n-drop @var{position} @var{files}) |
1529 This kind of event is generated when a group of files is | 1538 This kind of event is generated when a group of files is |
1530 selected in an application outside of Emacs, and then dragged and | 1539 selected in an application outside of Emacs, and then dragged and |