1 /* Call a Lisp function interactively.
2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32 Lisp_Object Qminus
, Qplus
;
33 Lisp_Object Qcall_interactively
;
34 Lisp_Object Qcommand_debug_status
;
35 Lisp_Object Qenable_recursive_minibuffers
;
37 Lisp_Object Qhandle_shift_selection
;
39 Lisp_Object Qmouse_leave_buffer_hook
;
41 Lisp_Object Qlist
, Qlet
, Qletx
, Qsave_excursion
, Qprogn
, Qif
, Qwhen
;
42 static Lisp_Object preserved_fns
;
44 /* Marker used within call-interactively to refer to point. */
45 static Lisp_Object point_marker
;
47 /* String for the prompt text used in Fcall_interactively. */
48 static Lisp_Object callint_message
;
51 DEFUN ("interactive", Finteractive
, Sinteractive
, 0, UNEVALLED
, 0,
52 doc
: /* Specify a way of parsing arguments for interactive use of a function.
54 (defun foo (arg buf) "Doc string" (interactive "P\\nbbuffer: ") .... )
55 to make ARG be the raw prefix argument, and set BUF to an existing buffer,
56 when `foo' is called as a command.
57 The "call" to `interactive' is actually a declaration rather than a function;
58 it tells `call-interactively' how to read arguments
59 to pass to the function.
60 When actually called, `interactive' just returns nil.
62 Usually the argument of `interactive' is a string containing a code letter
63 followed optionally by a prompt. (Some code letters do not use I/O to get
64 the argument and do not use prompts.) To get several arguments, concatenate
65 the individual strings, separating them by newline characters.
66 Prompts are passed to format, and may use % escapes to print the
67 arguments that have already been read.
68 If the argument is not a string, it is evaluated to get a list of
69 arguments to pass to the function.
70 Just `(interactive)' means pass no args when calling interactively.
72 Code letters available are:
73 a -- Function name: symbol with a function definition.
74 b -- Name of existing buffer.
75 B -- Name of buffer, possibly nonexistent.
76 c -- Character (no input method is used).
77 C -- Command name: symbol with interactive function definition.
78 d -- Value of point as number. Does not do I/O.
80 e -- Parametrized event (i.e., one that's a list) that invoked this command.
81 If used more than once, the Nth `e' returns the Nth parameterized event.
82 This skips events that are integers or symbols.
83 f -- Existing file name.
84 F -- Possibly nonexistent file name.
85 G -- Possibly nonexistent file name, defaulting to just directory name.
86 i -- Ignored, i.e. always nil. Does not do I/O.
87 k -- Key sequence (downcase the last event if needed to get a definition).
88 K -- Key sequence to be redefined (do not downcase the last event).
89 m -- Value of mark as number. Does not do I/O.
90 M -- Any string. Inherits the current input method.
91 n -- Number read using minibuffer.
92 N -- Numeric prefix arg, or if none, do like code `n'.
93 p -- Prefix arg converted to number. Does not do I/O.
94 P -- Prefix arg in raw form. Does not do I/O.
95 r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O.
96 s -- Any string. Does not inherit the current input method.
98 U -- Mouse up event discarded by a previous k or K argument.
99 v -- Variable name: symbol that is user-variable-p.
100 x -- Lisp expression read but not evaluated.
101 X -- Lisp expression read and evaluated.
103 Z -- Coding system, nil if no prefix arg.
105 In addition, if the string begins with `*', an error is signaled if
106 the buffer is read-only.
107 If the string begins with `@', Emacs searches the key sequence which
108 invoked the command for its first mouse click (or any other event
109 which specifies a window).
110 If the string begins with `^' and `shift-select-mode' is non-nil,
111 Emacs first calls the function `handle-shift-selection'.
112 You may use `@', `*', and `^' together. They are processed in the
113 order that they appear, before reading any arguments.
114 usage: (interactive &optional ARGS) */)
120 /* Quotify EXP: if EXP is constant, return it.
121 If EXP is not constant, return (quote EXP). */
123 quotify_arg (register Lisp_Object exp
)
125 if (!INTEGERP (exp
) && !STRINGP (exp
)
126 && !NILP (exp
) && !EQ (exp
, Qt
))
127 return Fcons (Qquote
, Fcons (exp
, Qnil
));
132 /* Modify EXP by quotifying each element (except the first). */
134 quotify_args (Lisp_Object exp
)
136 register Lisp_Object tail
;
138 for (tail
= exp
; CONSP (tail
); tail
= next
)
141 XSETCAR (tail
, quotify_arg (XCAR (tail
)));
146 static const char *callint_argfuns
[]
147 = {"", "point", "mark", "region-beginning", "region-end"};
150 check_mark (int for_region
)
153 tem
= Fmarker_buffer (current_buffer
->mark
);
154 if (NILP (tem
) || (XBUFFER (tem
) != current_buffer
))
155 error (for_region
? "The mark is not set now, so there is no region"
156 : "The mark is not set now");
157 if (!NILP (Vtransient_mark_mode
) && NILP (Vmark_even_if_inactive
)
158 && NILP (current_buffer
->mark_active
))
159 xsignal0 (Qmark_inactive
);
162 /* If the list of args INPUT was produced with an explicit call to
163 `list', look for elements that were computed with
164 (region-beginning) or (region-end), and put those expressions into
165 VALUES instead of the present values.
167 This function doesn't return a value because it modifies elements
168 of VALUES to do its job. */
171 fix_command (Lisp_Object input
, Lisp_Object values
)
178 /* Skip through certain special forms. */
179 while (EQ (car
, Qlet
) || EQ (car
, Qletx
)
180 || EQ (car
, Qsave_excursion
)
183 while (CONSP (XCDR (input
)))
184 input
= XCDR (input
);
185 input
= XCAR (input
);
192 Lisp_Object intail
, valtail
;
193 for (intail
= Fcdr (input
), valtail
= values
;
195 intail
= Fcdr (intail
), valtail
= XCDR (valtail
))
201 Lisp_Object presflag
, carelt
;
203 /* If it is (if X Y), look at Y. */
205 && EQ (Fnthcdr (make_number (3), elt
), Qnil
))
206 elt
= Fnth (make_number (2), elt
);
207 /* If it is (when ... Y), look at Y. */
208 else if (EQ (carelt
, Qwhen
))
210 while (CONSP (XCDR (elt
)))
215 /* If the function call we're looking at
216 is a special preserved one, copy the
217 whole expression for this argument. */
220 presflag
= Fmemq (Fcar (elt
), preserved_fns
);
221 if (!NILP (presflag
))
222 Fsetcar (valtail
, Fcar (intail
));
230 DEFUN ("call-interactively", Fcall_interactively
, Scall_interactively
, 1, 3, 0,
231 doc
: /* Call FUNCTION, reading args according to its interactive calling specs.
232 Return the value FUNCTION returns.
233 The function contains a specification of how to do the argument reading.
234 In the case of user-defined functions, this is specified by placing a call
235 to the function `interactive' at the top level of the function body.
238 Optional second arg RECORD-FLAG non-nil
239 means unconditionally put this command in the command-history.
240 Otherwise, this is done only if an arg is read using the minibuffer.
242 Optional third arg KEYS, if given, specifies the sequence of events to
243 supply, as a vector, if the command inquires which events were used to
244 invoke it. If KEYS is omitted or nil, the return value of
245 `this-command-keys-vector' is used. */)
246 (Lisp_Object function
, Lisp_Object record_flag
, Lisp_Object keys
)
248 Lisp_Object
*args
, *visargs
;
250 Lisp_Object filter_specs
;
252 Lisp_Object up_event
;
254 int speccount
= SPECPDL_INDEX ();
256 /* The index of the next element of this_command_keys to examine for
257 the 'e' interactive code. */
260 Lisp_Object prefix_arg
;
261 unsigned char *string
;
264 /* If varies[i] > 0, the i'th argument shouldn't just have its value
265 in this call quoted in the command history. It should be
266 recorded as a call to the function named callint_argfuns[varies[i]]. */
273 int arg_from_tty
= 0;
274 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
;
276 int record_then_fail
= 0;
278 Lisp_Object save_this_command
, save_last_command
;
279 Lisp_Object save_this_original_command
, save_real_this_command
;
281 save_this_command
= Vthis_command
;
282 save_this_original_command
= Vthis_original_command
;
283 save_real_this_command
= real_this_command
;
284 save_last_command
= current_kboard
->Vlast_command
;
287 keys
= this_command_keys
, key_count
= this_command_key_count
;
291 key_count
= XVECTOR (keys
)->size
;
294 /* Save this now, since use of minibuffer will clobber it. */
295 prefix_arg
= Vcurrent_prefix_arg
;
297 if (SYMBOLP (function
))
298 enable
= Fget (function
, Qenable_recursive_minibuffers
);
304 /* The idea of FILTER_SPECS is to provide away to
305 specify how to represent the arguments in command history.
306 The feature is not fully implemented. */
309 /* If k or K discard an up-event, save it here so it can be retrieved with U */
312 /* Set SPECS to the interactive form, or barf if not interactive. */
315 GCPRO2 (function
, prefix_arg
);
316 form
= Finteractive_form (function
);
319 specs
= filter_specs
= Fcar (XCDR (form
));
321 wrong_type_argument (Qcommandp
, function
);
324 /* If SPECS is set to a string, use it as an interactive prompt. */
327 /* Make a copy of string so that if a GC relocates specs,
328 `string' will still be valid. */
329 string
= (unsigned char *) alloca (SBYTES (specs
) + 1);
330 memcpy (string
, SDATA (specs
), SBYTES (specs
) + 1);
335 i
= num_input_events
;
337 /* Compute the arg values using the user's expression. */
338 GCPRO2 (input
, filter_specs
);
339 specs
= Feval (specs
);
341 if (i
!= num_input_events
|| !NILP (record_flag
))
343 /* We should record this command on the command history. */
345 Lisp_Object this_cmd
;
346 /* Make a copy of the list of values, for the command history,
347 and turn them into things we can eval. */
348 values
= quotify_args (Fcopy_sequence (specs
));
349 fix_command (input
, values
);
350 this_cmd
= Fcons (function
, values
);
351 if (history_delete_duplicates
)
352 Vcommand_history
= Fdelete (this_cmd
, Vcommand_history
);
353 Vcommand_history
= Fcons (this_cmd
, Vcommand_history
);
355 /* Don't keep command history around forever. */
356 if (INTEGERP (Vhistory_length
) && XINT (Vhistory_length
) > 0)
358 teml
= Fnthcdr (Vhistory_length
, Vcommand_history
);
360 XSETCDR (teml
, Qnil
);
364 Vthis_command
= save_this_command
;
365 Vthis_original_command
= save_this_original_command
;
366 real_this_command
= save_real_this_command
;
367 current_kboard
->Vlast_command
= save_last_command
;
369 temporarily_switch_to_single_kboard (NULL
);
370 return unbind_to (speccount
, apply1 (function
, specs
));
373 /* Here if function specifies a string to control parsing the defaults */
375 /* Set next_event to point to the first event with parameters. */
376 for (next_event
= 0; next_event
< key_count
; next_event
++)
377 if (EVENT_HAS_PARAMETERS (AREF (keys
, next_event
)))
380 /* Handle special starting chars `*' and `@'. Also `-'. */
381 /* Note that `+' is reserved for user extensions. */
385 error ("`+' is not used in `interactive' for ordinary commands");
386 else if (*string
== '*')
389 if (!NILP (current_buffer
->read_only
))
391 if (!NILP (record_flag
))
393 unsigned char *p
= string
;
396 if (! (*p
== 'r' || *p
== 'p' || *p
== 'P'
398 Fbarf_if_buffer_read_only ();
401 record_then_fail
= 1;
404 Fbarf_if_buffer_read_only ();
407 /* Ignore this for semi-compatibility with Lucid. */
408 else if (*string
== '-')
410 else if (*string
== '@')
412 Lisp_Object event
, tem
;
414 event
= (next_event
< key_count
415 ? AREF (keys
, next_event
)
417 if (EVENT_HAS_PARAMETERS (event
)
418 && (tem
= XCDR (event
), CONSP (tem
))
419 && (tem
= XCAR (tem
), CONSP (tem
))
420 && (tem
= XCAR (tem
), WINDOWP (tem
)))
422 if (MINI_WINDOW_P (XWINDOW (tem
))
423 && ! (minibuf_level
> 0 && EQ (tem
, minibuf_window
)))
424 error ("Attempt to select inactive minibuffer window");
426 /* If the current buffer wants to clean up, let it. */
427 if (!NILP (Vmouse_leave_buffer_hook
))
428 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
430 Fselect_window (tem
, Qnil
);
434 else if (*string
== '^')
436 call0 (Qhandle_shift_selection
);
442 /* Count the number of arguments the interactive spec would have
443 us give to the function. */
447 /* 'r' specifications ("point and mark as 2 numeric args")
448 produce *two* arguments. */
453 tem
= (unsigned char *) strchr (tem
, '\n');
461 args
= (Lisp_Object
*) alloca ((count
+ 1) * sizeof (Lisp_Object
));
462 visargs
= (Lisp_Object
*) alloca ((count
+ 1) * sizeof (Lisp_Object
));
463 varies
= (int *) alloca ((count
+ 1) * sizeof (int));
465 for (i
= 0; i
< (count
+ 1); i
++)
472 GCPRO5 (prefix_arg
, function
, *args
, *visargs
, up_event
);
473 gcpro3
.nvars
= (count
+ 1);
474 gcpro4
.nvars
= (count
+ 1);
477 specbind (Qenable_recursive_minibuffers
, Qt
);
480 for (i
= 1; *tem
; i
++)
482 strncpy (prompt1
, tem
+ 1, sizeof prompt1
- 1);
483 prompt1
[sizeof prompt1
- 1] = 0;
484 tem1
= strchr (prompt1
, '\n');
487 visargs
[0] = build_string (prompt1
);
488 if (strchr (prompt1
, '%'))
489 callint_message
= Fformat (i
, visargs
);
491 callint_message
= visargs
[0];
495 case 'a': /* Symbol defined as a function */
496 visargs
[i
] = Fcompleting_read (callint_message
,
497 Vobarray
, Qfboundp
, Qt
,
498 Qnil
, Qnil
, Qnil
, Qnil
);
499 /* Passing args[i] directly stimulates compiler bug */
501 args
[i
] = Fintern (teml
, Qnil
);
504 case 'b': /* Name of existing buffer */
505 args
[i
] = Fcurrent_buffer ();
506 if (EQ (selected_window
, minibuf_window
))
507 args
[i
] = Fother_buffer (args
[i
], Qnil
, Qnil
);
508 args
[i
] = Fread_buffer (callint_message
, args
[i
], Qt
);
511 case 'B': /* Name of buffer, possibly nonexistent */
512 args
[i
] = Fread_buffer (callint_message
,
513 Fother_buffer (Fcurrent_buffer (), Qnil
, Qnil
),
517 case 'c': /* Character */
518 /* Prompt in `minibuffer-prompt' face. */
519 Fput_text_property (make_number (0),
520 make_number (SCHARS (callint_message
)),
521 Qface
, Qminibuffer_prompt
, callint_message
);
522 args
[i
] = Fread_char (callint_message
, Qnil
, Qnil
);
523 message1_nolog ((char *) 0);
524 /* Passing args[i] directly stimulates compiler bug */
526 visargs
[i
] = Fchar_to_string (teml
);
529 case 'C': /* Command: symbol with interactive function */
530 visargs
[i
] = Fcompleting_read (callint_message
,
532 Qt
, Qnil
, Qnil
, Qnil
, Qnil
);
533 /* Passing args[i] directly stimulates compiler bug */
535 args
[i
] = Fintern (teml
, Qnil
);
538 case 'd': /* Value of point. Does not do I/O. */
539 set_marker_both (point_marker
, Qnil
, PT
, PT_BYTE
);
540 args
[i
] = point_marker
;
541 /* visargs[i] = Qnil; */
545 case 'D': /* Directory name. */
546 args
[i
] = Fread_file_name (callint_message
, Qnil
,
547 current_buffer
->directory
, Qlambda
, Qnil
,
551 case 'f': /* Existing file name. */
552 args
[i
] = Fread_file_name (callint_message
,
553 Qnil
, Qnil
, Qlambda
, Qnil
, Qnil
);
556 case 'F': /* Possibly nonexistent file name. */
557 args
[i
] = Fread_file_name (callint_message
,
558 Qnil
, Qnil
, Qnil
, Qnil
, Qnil
);
561 case 'G': /* Possibly nonexistent file name,
562 default to directory alone. */
563 args
[i
] = Fread_file_name (callint_message
,
564 Qnil
, Qnil
, Qnil
, empty_unibyte_string
, Qnil
);
567 case 'i': /* Ignore an argument -- Does not do I/O */
571 case 'k': /* Key sequence. */
573 int speccount1
= SPECPDL_INDEX ();
574 specbind (Qcursor_in_echo_area
, Qt
);
575 /* Prompt in `minibuffer-prompt' face. */
576 Fput_text_property (make_number (0),
577 make_number (SCHARS (callint_message
)),
578 Qface
, Qminibuffer_prompt
, callint_message
);
579 args
[i
] = Fread_key_sequence (callint_message
,
580 Qnil
, Qnil
, Qnil
, Qnil
);
581 unbind_to (speccount1
, Qnil
);
583 visargs
[i
] = Fkey_description (teml
, Qnil
);
585 /* If the key sequence ends with a down-event,
586 discard the following up-event. */
587 teml
= Faref (args
[i
], make_number (XINT (Flength (args
[i
])) - 1));
594 teml
= Fget (teml
, intern ("event-symbol-elements"));
595 /* Ignore first element, which is the base key. */
596 tem2
= Fmemq (intern ("down"), Fcdr (teml
));
598 up_event
= Fread_event (Qnil
, Qnil
, Qnil
);
603 case 'K': /* Key sequence to be defined. */
605 int speccount1
= SPECPDL_INDEX ();
606 specbind (Qcursor_in_echo_area
, Qt
);
607 /* Prompt in `minibuffer-prompt' face. */
608 Fput_text_property (make_number (0),
609 make_number (SCHARS (callint_message
)),
610 Qface
, Qminibuffer_prompt
, callint_message
);
611 args
[i
] = Fread_key_sequence (callint_message
,
612 Qnil
, Qt
, Qnil
, Qnil
);
614 visargs
[i
] = Fkey_description (teml
, Qnil
);
615 unbind_to (speccount1
, Qnil
);
617 /* If the key sequence ends with a down-event,
618 discard the following up-event. */
619 teml
= Faref (args
[i
], make_number (XINT (Flength (args
[i
])) - 1));
626 teml
= Fget (teml
, intern ("event-symbol-elements"));
627 /* Ignore first element, which is the base key. */
628 tem2
= Fmemq (intern ("down"), Fcdr (teml
));
630 up_event
= Fread_event (Qnil
, Qnil
, Qnil
);
635 case 'U': /* Up event from last k or K */
636 if (!NILP (up_event
))
638 args
[i
] = Fmake_vector (make_number (1), up_event
);
641 visargs
[i
] = Fkey_description (teml
, Qnil
);
645 case 'e': /* The invoking event. */
646 if (next_event
>= key_count
)
647 error ("%s must be bound to an event with parameters",
649 ? SSDATA (SYMBOL_NAME (function
))
651 args
[i
] = AREF (keys
, next_event
);
655 /* Find the next parameterized event. */
656 while (next_event
< key_count
657 && !(EVENT_HAS_PARAMETERS (AREF (keys
, next_event
))))
662 case 'm': /* Value of mark. Does not do I/O. */
664 /* visargs[i] = Qnil; */
665 args
[i
] = current_buffer
->mark
;
669 case 'M': /* String read via minibuffer with
670 inheriting the current input method. */
671 args
[i
] = Fread_string (callint_message
,
672 Qnil
, Qnil
, Qnil
, Qt
);
675 case 'N': /* Prefix arg as number, else number from minibuffer */
676 if (!NILP (prefix_arg
))
677 goto have_prefix_arg
;
678 case 'n': /* Read number from minibuffer. */
686 message ("Please enter a number.");
687 sit_for (make_number (1), 0, 0);
691 tem
= Fread_from_minibuffer (callint_message
,
692 Qnil
, Qnil
, Qnil
, Qnil
, Qnil
,
694 if (! STRINGP (tem
) || SCHARS (tem
) == 0)
697 args
[i
] = Fread (tem
);
699 while (! NUMBERP (args
[i
]));
701 visargs
[i
] = args
[i
];
704 case 'P': /* Prefix arg in raw form. Does no I/O. */
705 args
[i
] = prefix_arg
;
706 /* visargs[i] = Qnil; */
710 case 'p': /* Prefix arg converted to number. No I/O. */
712 args
[i
] = Fprefix_numeric_value (prefix_arg
);
713 /* visargs[i] = Qnil; */
717 case 'r': /* Region, point and mark as 2 args. */
719 set_marker_both (point_marker
, Qnil
, PT
, PT_BYTE
);
720 /* visargs[i+1] = Qnil; */
721 foo
= marker_position (current_buffer
->mark
);
722 /* visargs[i] = Qnil; */
723 args
[i
] = PT
< foo
? point_marker
: current_buffer
->mark
;
725 args
[++i
] = PT
> foo
? point_marker
: current_buffer
->mark
;
729 case 's': /* String read via minibuffer without
730 inheriting the current input method. */
731 args
[i
] = Fread_string (callint_message
,
732 Qnil
, Qnil
, Qnil
, Qnil
);
735 case 'S': /* Any symbol. */
736 visargs
[i
] = Fread_string (callint_message
,
737 Qnil
, Qnil
, Qnil
, Qnil
);
738 /* Passing args[i] directly stimulates compiler bug */
740 args
[i
] = Fintern (teml
, Qnil
);
743 case 'v': /* Variable name: symbol that is
745 args
[i
] = Fread_variable (callint_message
, Qnil
);
746 visargs
[i
] = last_minibuf_string
;
749 case 'x': /* Lisp expression read but not evaluated */
750 args
[i
] = Fread_minibuffer (callint_message
, Qnil
);
751 visargs
[i
] = last_minibuf_string
;
754 case 'X': /* Lisp expression read and evaluated */
755 args
[i
] = Feval_minibuffer (callint_message
, Qnil
);
756 visargs
[i
] = last_minibuf_string
;
759 case 'Z': /* Coding-system symbol, or ignore the
760 argument if no prefix */
761 if (NILP (prefix_arg
))
769 = Fread_non_nil_coding_system (callint_message
);
770 visargs
[i
] = last_minibuf_string
;
774 case 'z': /* Coding-system symbol or nil */
775 args
[i
] = Fread_coding_system (callint_message
, Qnil
);
776 visargs
[i
] = last_minibuf_string
;
779 /* We have a case for `+' so we get an error
780 if anyone tries to define one here. */
783 error ("Invalid control letter `%c' (%03o) in interactive calling string",
790 if (NILP (visargs
[i
]) && STRINGP (args
[i
]))
791 visargs
[i
] = args
[i
];
793 tem
= (unsigned char *) strchr (tem
, '\n');
795 else tem
= (unsigned char *) "";
797 unbind_to (speccount
, Qnil
);
803 if (arg_from_tty
|| !NILP (record_flag
))
805 visargs
[0] = function
;
806 for (i
= 1; i
< count
+ 1; i
++)
809 visargs
[i
] = Fcons (intern (callint_argfuns
[varies
[i
]]), Qnil
);
811 visargs
[i
] = quotify_arg (args
[i
]);
813 Vcommand_history
= Fcons (Flist (count
+ 1, visargs
),
815 /* Don't keep command history around forever. */
816 if (INTEGERP (Vhistory_length
) && XINT (Vhistory_length
) > 0)
818 teml
= Fnthcdr (Vhistory_length
, Vcommand_history
);
820 XSETCDR (teml
, Qnil
);
824 /* If we used a marker to hold point, mark, or an end of the region,
825 temporarily, convert it to an integer now. */
826 for (i
= 1; i
<= count
; i
++)
827 if (varies
[i
] >= 1 && varies
[i
] <= 4)
828 XSETINT (args
[i
], marker_position (args
[i
]));
830 if (record_then_fail
)
831 Fbarf_if_buffer_read_only ();
833 Vthis_command
= save_this_command
;
834 Vthis_original_command
= save_this_original_command
;
835 real_this_command
= save_real_this_command
;
836 current_kboard
->Vlast_command
= save_last_command
;
840 specbind (Qcommand_debug_status
, Qnil
);
842 temporarily_switch_to_single_kboard (NULL
);
843 val
= Ffuncall (count
+ 1, args
);
845 return unbind_to (speccount
, val
);
849 DEFUN ("prefix-numeric-value", Fprefix_numeric_value
, Sprefix_numeric_value
,
851 doc
: /* Return numeric meaning of raw prefix argument RAW.
852 A raw prefix argument is what you get from `(interactive "P")'.
853 Its numeric meaning is what you would get from `(interactive "p")'. */)
859 XSETFASTINT (val
, 1);
860 else if (EQ (raw
, Qminus
))
862 else if (CONSP (raw
) && INTEGERP (XCAR (raw
)))
863 XSETINT (val
, XINT (XCAR (raw
)));
864 else if (INTEGERP (raw
))
867 XSETFASTINT (val
, 1);
873 syms_of_callint (void)
875 point_marker
= Fmake_marker ();
876 staticpro (&point_marker
);
878 callint_message
= Qnil
;
879 staticpro (&callint_message
);
881 preserved_fns
= pure_cons (intern_c_string ("region-beginning"),
882 pure_cons (intern_c_string ("region-end"),
883 pure_cons (intern_c_string ("point"),
884 pure_cons (intern_c_string ("mark"), Qnil
))));
886 Qlist
= intern_c_string ("list");
888 Qlet
= intern_c_string ("let");
890 Qif
= intern_c_string ("if");
892 Qwhen
= intern_c_string ("when");
894 Qletx
= intern_c_string ("let*");
896 Qsave_excursion
= intern_c_string ("save-excursion");
897 staticpro (&Qsave_excursion
);
898 Qprogn
= intern_c_string ("progn");
901 Qminus
= intern_c_string ("-");
904 Qplus
= intern_c_string ("+");
907 Qhandle_shift_selection
= intern_c_string ("handle-shift-selection");
908 staticpro (&Qhandle_shift_selection
);
910 Qcall_interactively
= intern_c_string ("call-interactively");
911 staticpro (&Qcall_interactively
);
913 Qcommand_debug_status
= intern_c_string ("command-debug-status");
914 staticpro (&Qcommand_debug_status
);
916 Qenable_recursive_minibuffers
= intern_c_string ("enable-recursive-minibuffers");
917 staticpro (&Qenable_recursive_minibuffers
);
919 Qmouse_leave_buffer_hook
= intern_c_string ("mouse-leave-buffer-hook");
920 staticpro (&Qmouse_leave_buffer_hook
);
922 DEFVAR_KBOARD ("prefix-arg", Vprefix_arg
,
923 doc
: /* The value of the prefix argument for the next editing command.
924 It may be a number, or the symbol `-' for just a minus sign as arg,
925 or a list whose car is a number for just one or more C-u's
926 or nil if no argument has been specified.
928 You cannot examine this variable to find the argument for this command
929 since it has been set to nil by the time you can look.
930 Instead, you should use the variable `current-prefix-arg', although
931 normally commands can get this prefix argument with (interactive "P"). */);
933 DEFVAR_KBOARD ("last-prefix-arg", Vlast_prefix_arg
,
934 doc
: /* The value of the prefix argument for the previous editing command.
935 See `prefix-arg' for the meaning of the value. */);
937 DEFVAR_LISP ("current-prefix-arg", Vcurrent_prefix_arg
,
938 doc
: /* The value of the prefix argument for this editing command.
939 It may be a number, or the symbol `-' for just a minus sign as arg,
940 or a list whose car is a number for just one or more C-u's
941 or nil if no argument has been specified.
942 This is what `(interactive \"P\")' returns. */);
943 Vcurrent_prefix_arg
= Qnil
;
945 DEFVAR_LISP ("command-history", Vcommand_history
,
946 doc
: /* List of recent commands that read arguments from terminal.
947 Each command is represented as a form to evaluate.
949 Maximum length of the history list is determined by the value
950 of `history-length', which see. */);
951 Vcommand_history
= Qnil
;
953 DEFVAR_LISP ("command-debug-status", Vcommand_debug_status
,
954 doc
: /* Debugging status of current interactive command.
955 Bound each time `call-interactively' is called;
956 may be set by the debugger as a reminder for itself. */);
957 Vcommand_debug_status
= Qnil
;
959 DEFVAR_LISP ("mark-even-if-inactive", Vmark_even_if_inactive
,
960 doc
: /* *Non-nil means you can use the mark even when inactive.
961 This option makes a difference in Transient Mark mode.
962 When the option is non-nil, deactivation of the mark
963 turns off region highlighting, but commands that use the mark
964 behave as if the mark were still active. */);
965 Vmark_even_if_inactive
= Qt
;
967 DEFVAR_LISP ("mouse-leave-buffer-hook", Vmouse_leave_buffer_hook
,
968 doc
: /* Hook to run when about to switch windows with a mouse command.
969 Its purpose is to give temporary modes such as Isearch mode
970 a way to turn themselves off when a mouse command switches windows. */);
971 Vmouse_leave_buffer_hook
= Qnil
;
973 defsubr (&Sinteractive
);
974 defsubr (&Scall_interactively
);
975 defsubr (&Sprefix_numeric_value
);