aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1995-03-08 03:32:30 +0000
committerKarl Heuer1995-03-08 03:32:30 +0000
commit1cf9cfc6636ae2667da810df82d0c5bafa42ab84 (patch)
tree2ad238a573a98c61f00946808032511bffa78e60 /src
parent5169b66ddc167f17660453982e73a1c379d2132e (diff)
downloademacs-1cf9cfc6636ae2667da810df82d0c5bafa42ab84.tar.gz
emacs-1cf9cfc6636ae2667da810df82d0c5bafa42ab84.zip
(current_prefix_partial): New var.
(Funiversal_argument): New function, formerly inlined in keyboard.c. (Fnegative_argument, Fdigit_argument): Likewise. (clear_prefix_arg): Moved here from keyboard.c. Don't clear the internal state if we're still building a prefix arg. (finalize_prefix_arg, describe_prefix_arg): Moved from keyboard.c. (syms_of_callint): defsubr the new lisp-callable functions.
Diffstat (limited to 'src')
-rw-r--r--src/callint.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/callint.c b/src/callint.c
index 0bc1c996366..23907c7f151 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -28,6 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
28 28
29extern char *index (); 29extern char *index ();
30 30
31int current_prefix_partial;
31Lisp_Object Vprefix_arg, Vcurrent_prefix_arg, Qminus, Qplus; 32Lisp_Object Vprefix_arg, Vcurrent_prefix_arg, Qminus, Qplus;
32Lisp_Object Qcall_interactively; 33Lisp_Object Qcall_interactively;
33Lisp_Object Vcommand_history; 34Lisp_Object Vcommand_history;
@@ -47,6 +48,48 @@ static Lisp_Object preserved_fns;
47/* Marker used within call-interactively to refer to point. */ 48/* Marker used within call-interactively to refer to point. */
48static Lisp_Object point_marker; 49static Lisp_Object point_marker;
49 50
51
52void
53clear_prefix_arg ()
54{
55 if (!current_perdisplay)
56 abort ();
57 Vprefix_arg = Qnil;
58 if (!current_prefix_partial)
59 {
60 current_perdisplay->prefix_factor = Qnil;
61 current_perdisplay->prefix_value = Qnil;
62 current_perdisplay->prefix_sign = 1;
63 current_perdisplay->prefix_partial = 0;
64 }
65}
66
67void
68finalize_prefix_arg ()
69{
70 if (!NILP (current_perdisplay->prefix_factor))
71 Vprefix_arg = Fcons (current_perdisplay->prefix_factor, Qnil);
72 else if (NILP (current_perdisplay->prefix_value))
73 Vprefix_arg = (current_perdisplay->prefix_sign > 0 ? Qnil : Qminus);
74 else if (current_perdisplay->prefix_sign > 0)
75 Vprefix_arg = current_perdisplay->prefix_value;
76 else
77 XSETINT (Vprefix_arg, -XINT (current_perdisplay->prefix_value));
78 current_perdisplay->prefix_partial = 0;
79}
80
81static void
82describe_prefix_arg ()
83{
84 if (INTEGERP (Vprefix_arg))
85 message ("Arg: %d", Vprefix_arg);
86 else if (CONSP (Vprefix_arg))
87 message ("Arg: [%d]", XCONS (Vprefix_arg)->car);
88 else if (EQ (Vprefix_arg, Qminus))
89 message ("Arg: -");
90}
91
92
50/* This comment supplies the doc string for interactive, 93/* This comment supplies the doc string for interactive,
51 for make-docfile to see. We cannot put this in the real DEFUN 94 for make-docfile to see. We cannot put this in the real DEFUN
52 due to limits in the Unix cpp. 95 due to limits in the Unix cpp.
@@ -652,6 +695,65 @@ Its numeric meaning is what you would get from `(interactive \"p\")'.")
652 return val; 695 return val;
653} 696}
654 697
698DEFUN ("universal-argument", Funiversal_argument, Suniversal_argument, 0, 0, "",
699 "Begin a numeric argument for the following command.\n\
700Digits or minus sign following \\[universal-argument] make up the numeric argument.\n\
701\\[universal-argument] following the digits or minus sign ends the argument.\n\
702\\[universal-argument] without digits or minus sign provides 4 as argument.\n\
703Repeating \\[universal-argument] without digits or minus sign\n\
704 multiplies the argument by 4 each time.")
705 ()
706{
707 if (!current_prefix_partial)
708 {
709 /* First C-u */
710 XSETFASTINT (current_perdisplay->prefix_factor, 4);
711 current_perdisplay->prefix_value = Qnil;
712 current_perdisplay->prefix_sign = 1;
713 current_perdisplay->prefix_partial = 1;
714 }
715 else if (!NILP (current_perdisplay->prefix_factor))
716 {
717 /* Subsequent C-u */
718 XSETINT (current_perdisplay->prefix_factor,
719 XINT (current_perdisplay->prefix_factor) * 4);
720 current_perdisplay->prefix_partial = 1;
721 }
722 else
723 {
724 /* Terminating C-u */
725 finalize_prefix_arg ();
726 describe_prefix_arg ();
727 }
728}
729
730DEFUN ("negative-argument", Fnegative_argument, Snegative_argument, 0, 0, "",
731 "Begin a negative numeric argument for the next command.\n\
732\\[universal-argument] following digits or minus sign ends the argument.")
733 ()
734{
735 current_perdisplay->prefix_factor = Qnil;
736 current_perdisplay->prefix_sign *= -1;
737 current_perdisplay->prefix_partial = 1;
738}
739
740DEFUN ("digit-argument", Fdigit_argument, Sdigit_argument, 0, 0, "",
741 "Part of the numeric argument for the next command.\n\
742\\[universal-argument] following digits or minus sign ends the argument.")
743 ()
744{
745 int c;
746 if (!(INTEGERP (last_command_char)
747 && (c = (XINT (last_command_char) & 0177)) >= '0' && c <= '9'))
748 error("digit-argument must be bound to a digit key");
749 current_perdisplay->prefix_factor = Qnil;
750 if (NILP (current_perdisplay->prefix_value))
751 XSETFASTINT (current_perdisplay->prefix_value, 0);
752 XSETINT (current_perdisplay->prefix_value,
753 XINT (current_perdisplay->prefix_value) * 10 + (c - '0'));
754 current_perdisplay->prefix_partial = 1;
755}
756
655syms_of_callint () 757syms_of_callint ()
656{ 758{
657 point_marker = Fmake_marker (); 759 point_marker = Fmake_marker ();
@@ -732,4 +834,7 @@ a way to turn themselves off when a mouse command switches windows.");
732 defsubr (&Sinteractive); 834 defsubr (&Sinteractive);
733 defsubr (&Scall_interactively); 835 defsubr (&Scall_interactively);
734 defsubr (&Sprefix_numeric_value); 836 defsubr (&Sprefix_numeric_value);
837 defsubr (&Suniversal_argument);
838 defsubr (&Snegative_argument);
839 defsubr (&Sdigit_argument);
735} 840}