aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/eval.c b/src/eval.c
index 41085cdef5c..08df4e9ccfd 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,5 +1,5 @@
1/* Evaluator for GNU Emacs Lisp interpreter. 1/* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000 2 Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000, 2001
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -551,6 +551,7 @@ In byte compilation, `function' causes its argument to be compiled.\n\
551 return Fcar (args); 551 return Fcar (args);
552} 552}
553 553
554
554DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, 555DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
555 "Return t if function in which this appears was called interactively.\n\ 556 "Return t if function in which this appears was called interactively.\n\
556This means that the function was called with call-interactively (which\n\ 557This means that the function was called with call-interactively (which\n\
@@ -558,16 +559,33 @@ includes being called as the binding of a key)\n\
558and input is currently coming from the keyboard (not in keyboard macro).") 559and input is currently coming from the keyboard (not in keyboard macro).")
559 () 560 ()
560{ 561{
561 register struct backtrace *btp; 562 return interactive_p (1) ? Qt : Qnil;
562 register Lisp_Object fun; 563}
564
565
566/* Return 1 if function in which this appears was called
567 interactively. This means that the function was called with
568 call-interactively (which includes being called as the binding of
569 a key) and input is currently coming from the keyboard (not in
570 keyboard macro).
571
572 EXCLUDE_SUBRS_P non-zero means always return 0 if the function
573 called is a built-in. */
574
575int
576interactive_p (exclude_subrs_p)
577 int exclude_subrs_p;
578{
579 struct backtrace *btp;
580 Lisp_Object fun;
563 581
564 if (!INTERACTIVE) 582 if (!INTERACTIVE)
565 return Qnil; 583 return 0;
566 584
567 btp = backtrace_list; 585 btp = backtrace_list;
568 586
569 /* If this isn't a byte-compiled function, there may be a frame at 587 /* If this isn't a byte-compiled function, there may be a frame at
570 the top for Finteractive_p itself. If so, skip it. */ 588 the top for Finteractive_p. If so, skip it. */
571 fun = Findirect_function (*btp->function); 589 fun = Findirect_function (*btp->function);
572 if (SUBRP (fun) && XSUBR (fun) == &Sinteractive_p) 590 if (SUBRP (fun) && XSUBR (fun) == &Sinteractive_p)
573 btp = btp->next; 591 btp = btp->next;
@@ -591,15 +609,17 @@ and input is currently coming from the keyboard (not in keyboard macro).")
591 Fbytecode at the top. If this frame is for a built-in function 609 Fbytecode at the top. If this frame is for a built-in function
592 (such as load or eval-region) return nil. */ 610 (such as load or eval-region) return nil. */
593 fun = Findirect_function (*btp->function); 611 fun = Findirect_function (*btp->function);
594 if (SUBRP (fun)) 612 if (exclude_subrs_p && SUBRP (fun))
595 return Qnil; 613 return 0;
614
596 /* btp points to the frame of a Lisp function that called interactive-p. 615 /* btp points to the frame of a Lisp function that called interactive-p.
597 Return t if that function was called interactively. */ 616 Return t if that function was called interactively. */
598 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) 617 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively))
599 return Qt; 618 return 1;
600 return Qnil; 619 return 0;
601} 620}
602 621
622
603DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, 623DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0,
604 "Define NAME as a function.\n\ 624 "Define NAME as a function.\n\
605The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\ 625The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\