comparison src/eval.c @ 104290:ced4690576f6

* eval.c (Fcalled_interactively_p, Finteractive_p): Doc fix (Bug#3936).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 15 Aug 2009 21:51:33 +0000
parents 2658bfb08516
children 02a71b0c9a96
comparison
equal deleted inserted replaced
104289:3c79de4c87a1 104290:ced4690576f6
584 return Fcar (args); 584 return Fcar (args);
585 } 585 }
586 586
587 587
588 DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, 588 DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
589 doc: /* Return t if the function was run directly by user input. 589 doc: /* Return t if the containing function was run directly by user input.
590 This means that the function was called with `call-interactively' 590 This means that the function was called with `call-interactively'
591 \(which includes being called as the binding of a key) 591 \(which includes being called as the binding of a key)
592 and input is currently coming from the keyboard (not in keyboard macro), 592 and input is currently coming from the keyboard (not a keyboard macro),
593 and Emacs is not running in batch mode (`noninteractive' is nil). 593 and Emacs is not running in batch mode (`noninteractive' is nil).
594 594
595 The only known proper use of `interactive-p' is in deciding whether to 595 The only known proper use of `interactive-p' is in deciding whether to
596 display a helpful message, or how to display it. If you're thinking 596 display a helpful message, or how to display it. If you're thinking
597 of using it for any other purpose, it is quite likely that you're 597 of using it for any other purpose, it is quite likely that you're
598 making a mistake. Think: what do you want to do when the command is 598 making a mistake. Think: what do you want to do when the command is
599 called from a keyboard macro? 599 called from a keyboard macro?
600 600
601 If you want to test whether your function was called with 601 To test whether your function was called with `call-interactively',
602 `call-interactively', the way to do that is by adding an extra 602 either (i) add an extra optional argument and give it an `interactive'
603 optional argument, and making the `interactive' spec specify non-nil 603 spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
604 unconditionally for that argument. (`p' is a good way to do this.) */) 604 use `called-interactively-p'. */)
605 () 605 ()
606 { 606 {
607 return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil; 607 return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil;
608 } 608 }
609 609
610 610
611 DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0, 611 DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0,
612 doc: /* Return t if it is in a function called with `call-interactively'. 612 doc: /* Return t if the containing function was called by `call-interactively'.
613 This is used for implementing advice and other function-modifying 613 This includes being called as the binding of a key, or called from a
614 features of Emacs. 614 keyboard macro (unlike `interactive-p').
615 615
616 The cleanest way to test whether your function was called with 616 This function is meant for implementing advice and other
617 `call-interactively' is by adding an extra optional argument, 617 function-modifying features. Instead of using this, it is sometimes
618 and making the `interactive' spec specify non-nil unconditionally 618 cleaner to give your function an extra optional argument whose
619 for that argument. (`p' is a good way to do this.) */) 619 `interactive' spec specifies non-nil unconditionally (\"p\" is a good
620 way to do this). */)
620 () 621 ()
621 { 622 {
622 return interactive_p (1) ? Qt : Qnil; 623 return interactive_p (1) ? Qt : Qnil;
623 } 624 }
624 625