(change_frame_size_1): Reject new sizes if they cause overflow.
[emacs.git] / src / callint.c
blob5cedc443933b501f102875556ef1a0be5ef9dacb
1 /* Call a Lisp function interactively.
2 Copyright (C) 1985, 1986, 1993, 1994, 1995 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include <config.h>
23 #include "lisp.h"
24 #include "buffer.h"
25 #include "commands.h"
26 #include "keyboard.h"
27 #include "window.h"
28 #include "mocklisp.h"
30 extern char *index ();
32 extern Lisp_Object Qcursor_in_echo_area;
34 Lisp_Object Vcurrent_prefix_arg, Qminus, Qplus;
35 Lisp_Object Qcall_interactively;
36 Lisp_Object Vcommand_history;
38 Lisp_Object Vcommand_debug_status, Qcommand_debug_status;
39 Lisp_Object Qenable_recursive_minibuffers;
41 /* Non-nil means treat the mark as active
42 even if mark_active is 0. */
43 Lisp_Object Vmark_even_if_inactive;
45 Lisp_Object Vmouse_leave_buffer_hook, Qmouse_leave_buffer_hook;
47 Lisp_Object Qlist, Qlet, Qletx, Qsave_excursion;
48 static Lisp_Object preserved_fns;
50 /* Marker used within call-interactively to refer to point. */
51 static Lisp_Object point_marker;
53 /* Buffer for the prompt text used in Fcall_interactively. */
54 static char *callint_message;
56 /* Allocated length of that buffer. */
57 static int callint_message_size;
59 /* This comment supplies the doc string for interactive,
60 for make-docfile to see. We cannot put this in the real DEFUN
61 due to limits in the Unix cpp.
63 DEFUN ("interactive", Ffoo, Sfoo, 0, 0, 0,
64 "Specify a way of parsing arguments for interactive use of a function.\n\
65 For example, write\n\
66 (defun foo (arg) \"Doc string\" (interactive \"p\") ...use arg...)\n\
67 to make ARG be the prefix argument when `foo' is called as a command.\n\
68 The \"call\" to `interactive' is actually a declaration rather than a function;\n\
69 it tells `call-interactively' how to read arguments\n\
70 to pass to the function.\n\
71 When actually called, `interactive' just returns nil.\n\
72 \n\
73 The argument of `interactive' is usually a string containing a code letter\n\
74 followed by a prompt. (Some code letters do not use I/O to get\n\
75 the argument and do not need prompts.) To prompt for multiple arguments,\n\
76 give a code letter, its prompt, a newline, and another code letter, etc.\n\
77 Prompts are passed to format, and may use % escapes to print the\n\
78 arguments that have already been read.\n\
79 If the argument is not a string, it is evaluated to get a list of\n\
80 arguments to pass to the function.\n\
81 Just `(interactive)' means pass no args when calling interactively.\n\
82 \nCode letters available are:\n\
83 a -- Function name: symbol with a function definition.\n\
84 b -- Name of existing buffer.\n\
85 B -- Name of buffer, possibly nonexistent.\n\
86 c -- Character.\n\
87 C -- Command name: symbol with interactive function definition.\n\
88 d -- Value of point as number. Does not do I/O.\n\
89 D -- Directory name.\n\
90 e -- Parametrized event (i.e., one that's a list) that invoked this command.\n\
91 If used more than once, the Nth `e' returns the Nth parameterized event.\n\
92 This skips events that are integers or symbols.\n\
93 f -- Existing file name.\n\
94 F -- Possibly nonexistent file name.\n\
95 k -- Key sequence (downcase the last event if needed to get a definition).\n\
96 K -- Key sequence to be redefined (do not downcase the last event).\n\
97 m -- Value of mark as number. Does not do I/O.\n\
98 n -- Number read using minibuffer.\n\
99 N -- Raw prefix arg, or if none, do like code `n'.\n\
100 p -- Prefix arg converted to number. Does not do I/O.\n\
101 P -- Prefix arg in raw form. Does not do I/O.\n\
102 r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O.\n\
103 s -- Any string.\n\
104 S -- Any symbol.\n\
105 v -- Variable name: symbol that is user-variable-p.\n\
106 x -- Lisp expression read but not evaluated.\n\
107 X -- Lisp expression read and evaluated.\n\
108 In addition, if the string begins with `*'\n\
109 then an error is signaled if the buffer is read-only.\n\
110 This happens before reading any arguments.\n\
111 If the string begins with `@', then Emacs searches the key sequence\n\
112 which invoked the command for its first mouse click (or any other\n\
113 event which specifies a window), and selects that window before\n\
114 reading any arguments. You may use both `@' and `*'; they are\n\
115 processed in the order that they appear." */
117 /* ARGSUSED */
118 DEFUN ("interactive", Finteractive, Sinteractive, 0, UNEVALLED, 0,
119 0 /* See immediately above */)
120 (args)
121 Lisp_Object args;
123 return Qnil;
126 /* Quotify EXP: if EXP is constant, return it.
127 If EXP is not constant, return (quote EXP). */
128 Lisp_Object
129 quotify_arg (exp)
130 register Lisp_Object exp;
132 if (!INTEGERP (exp) && !STRINGP (exp)
133 && !NILP (exp) && !EQ (exp, Qt))
134 return Fcons (Qquote, Fcons (exp, Qnil));
136 return exp;
139 /* Modify EXP by quotifying each element (except the first). */
140 Lisp_Object
141 quotify_args (exp)
142 Lisp_Object exp;
144 register Lisp_Object tail;
145 register struct Lisp_Cons *ptr;
146 for (tail = exp; CONSP (tail); tail = ptr->cdr)
148 ptr = XCONS (tail);
149 ptr->car = quotify_arg (ptr->car);
151 return exp;
154 char *callint_argfuns[]
155 = {"", "point", "mark", "region-beginning", "region-end"};
157 static void
158 check_mark ()
160 Lisp_Object tem;
161 tem = Fmarker_buffer (current_buffer->mark);
162 if (NILP (tem) || (XBUFFER (tem) != current_buffer))
163 error ("The mark is not set now");
164 if (!NILP (Vtransient_mark_mode) && NILP (Vmark_even_if_inactive)
165 && NILP (current_buffer->mark_active))
166 Fsignal (Qmark_inactive, Qnil);
170 DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
171 "Call FUNCTION, reading args according to its interactive calling specs.\n\
172 Return the value FUNCTION returns.\n\
173 The function contains a specification of how to do the argument reading.\n\
174 In the case of user-defined functions, this is specified by placing a call\n\
175 to the function `interactive' at the top level of the function body.\n\
176 See `interactive'.\n\
178 Optional second arg RECORD-FLAG non-nil\n\
179 means unconditionally put this command in the command-history.\n\
180 Otherwise, this is done only if an arg is read using the minibuffer.")
181 (function, record_flag, keys)
182 Lisp_Object function, record_flag, keys;
184 Lisp_Object *args, *visargs;
185 unsigned char **argstrings;
186 Lisp_Object fun;
187 Lisp_Object funcar;
188 Lisp_Object specs;
189 Lisp_Object teml;
190 Lisp_Object enable;
191 int speccount = specpdl_ptr - specpdl;
193 /* The index of the next element of this_command_keys to examine for
194 the 'e' interactive code. */
195 int next_event;
197 Lisp_Object prefix_arg;
198 unsigned char *string;
199 unsigned char *tem;
201 /* If varies[i] > 0, the i'th argument shouldn't just have its value
202 in this call quoted in the command history. It should be
203 recorded as a call to the function named callint_argfuns[varies[i]]. */
204 int *varies;
206 register int i, j;
207 int count, foo;
208 char prompt1[100];
209 char *tem1;
210 int arg_from_tty = 0;
211 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
212 int key_count;
214 if (NILP (keys))
215 keys = this_command_keys, key_count = this_command_key_count;
216 else
218 CHECK_VECTOR (keys, 3);
219 key_count = XVECTOR (keys)->size;
222 /* Save this now, since use of minibuffer will clobber it. */
223 prefix_arg = Vcurrent_prefix_arg;
225 retry:
227 if (SYMBOLP (function))
228 enable = Fget (function, Qenable_recursive_minibuffers);
230 fun = indirect_function (function);
232 specs = Qnil;
233 string = 0;
235 /* Decode the kind of function. Either handle it and return,
236 or go to `lose' if not interactive, or go to `retry'
237 to specify a different function, or set either STRING or SPECS. */
239 if (SUBRP (fun))
241 string = (unsigned char *) XSUBR (fun)->prompt;
242 if (!string)
244 lose:
245 function = wrong_type_argument (Qcommandp, function);
246 goto retry;
248 if ((EMACS_INT) string == 1)
249 /* Let SPECS (which is nil) be used as the args. */
250 string = 0;
252 else if (COMPILEDP (fun))
254 if ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_INTERACTIVE)
255 goto lose;
256 specs = XVECTOR (fun)->contents[COMPILED_INTERACTIVE];
258 else if (!CONSP (fun))
259 goto lose;
260 else if (funcar = Fcar (fun), EQ (funcar, Qautoload))
262 GCPRO2 (function, prefix_arg);
263 do_autoload (fun, function);
264 UNGCPRO;
265 goto retry;
267 else if (EQ (funcar, Qlambda))
269 specs = Fassq (Qinteractive, Fcdr (Fcdr (fun)));
270 if (NILP (specs))
271 goto lose;
272 specs = Fcar (Fcdr (specs));
274 else if (EQ (funcar, Qmocklisp))
276 single_kboard_state ();
277 return ml_apply (fun, Qinteractive);
279 else
280 goto lose;
282 /* If either specs or string is set to a string, use it. */
283 if (STRINGP (specs))
285 /* Make a copy of string so that if a GC relocates specs,
286 `string' will still be valid. */
287 string = (unsigned char *) alloca (XSTRING (specs)->size + 1);
288 bcopy (XSTRING (specs)->data, string, XSTRING (specs)->size + 1);
290 else if (string == 0)
292 Lisp_Object input;
293 i = num_input_chars;
294 input = specs;
295 /* Compute the arg values using the user's expression. */
296 specs = Feval (specs);
297 if (i != num_input_chars || !NILP (record_flag))
299 /* We should record this command on the command history. */
300 Lisp_Object values, car;
301 /* Make a copy of the list of values, for the command history,
302 and turn them into things we can eval. */
303 values = quotify_args (Fcopy_sequence (specs));
304 /* If the list of args was produced with an explicit call to `list',
305 look for elements that were computed with (region-beginning)
306 or (region-end), and put those expressions into VALUES
307 instead of the present values. */
308 if (CONSP (input))
310 car = XCONS (input)->car;
311 /* Skip through certain special forms. */
312 while (EQ (car, Qlet) || EQ (car, Qletx)
313 || EQ (car, Qsave_excursion))
315 while (CONSP (XCONS (input)->cdr))
316 input = XCONS (input)->cdr;
317 input = XCONS (input)->car;
318 if (!CONSP (input))
319 break;
320 car = XCONS (input)->car;
322 if (EQ (car, Qlist))
324 Lisp_Object intail, valtail;
325 for (intail = Fcdr (input), valtail = values;
326 CONSP (valtail);
327 intail = Fcdr (intail), valtail = Fcdr (valtail))
329 Lisp_Object elt;
330 elt = Fcar (intail);
331 if (CONSP (elt))
333 Lisp_Object presflag;
334 presflag = Fmemq (Fcar (elt), preserved_fns);
335 if (!NILP (presflag))
336 Fsetcar (valtail, Fcar (intail));
341 Vcommand_history
342 = Fcons (Fcons (function, values), Vcommand_history);
344 single_kboard_state ();
345 return apply1 (function, specs);
348 /* Here if function specifies a string to control parsing the defaults */
350 /* Set next_event to point to the first event with parameters. */
351 for (next_event = 0; next_event < key_count; next_event++)
352 if (EVENT_HAS_PARAMETERS (XVECTOR (keys)->contents[next_event]))
353 break;
355 /* Handle special starting chars `*' and `@'. Also `-'. */
356 /* Note that `+' is reserved for user extensions. */
357 while (1)
359 if (*string == '+')
360 error ("`+' is not used in `interactive' for ordinary commands");
361 else if (*string == '*')
363 string++;
364 if (!NILP (current_buffer->read_only))
365 Fbarf_if_buffer_read_only ();
367 /* Ignore this for semi-compatibility with Lucid. */
368 else if (*string == '-')
369 string++;
370 else if (*string == '@')
372 Lisp_Object event;
374 event = XVECTOR (keys)->contents[next_event];
375 if (EVENT_HAS_PARAMETERS (event)
376 && (event = XCONS (event)->cdr, CONSP (event))
377 && (event = XCONS (event)->car, CONSP (event))
378 && (event = XCONS (event)->car, WINDOWP (event)))
380 if (MINI_WINDOW_P (XWINDOW (event))
381 && ! (minibuf_level > 0 && EQ (event, minibuf_window)))
382 error ("Attempt to select inactive minibuffer window");
384 /* If the current buffer wants to clean up, let it. */
385 if (!NILP (Vmouse_leave_buffer_hook))
386 call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
388 Fselect_window (event);
390 string++;
392 else break;
395 /* Count the number of arguments the interactive spec would have
396 us give to the function. */
397 tem = string;
398 for (j = 0; *tem; j++)
400 /* 'r' specifications ("point and mark as 2 numeric args")
401 produce *two* arguments. */
402 if (*tem == 'r') j++;
403 tem = (unsigned char *) index (tem, '\n');
404 if (tem)
405 tem++;
406 else
407 tem = (unsigned char *) "";
409 count = j;
411 args = (Lisp_Object *) alloca ((count + 1) * sizeof (Lisp_Object));
412 visargs = (Lisp_Object *) alloca ((count + 1) * sizeof (Lisp_Object));
413 argstrings = (unsigned char **) alloca ((count + 1) * sizeof (char *));
414 varies = (int *) alloca ((count + 1) * sizeof (int));
416 for (i = 0; i < (count + 1); i++)
418 args[i] = Qnil;
419 visargs[i] = Qnil;
420 varies[i] = 0;
423 GCPRO4 (prefix_arg, function, *args, *visargs);
424 gcpro3.nvars = (count + 1);
425 gcpro4.nvars = (count + 1);
427 if (!NILP (enable))
428 specbind (Qenable_recursive_minibuffers, Qt);
430 tem = string;
431 for (i = 1; *tem; i++)
433 strncpy (prompt1, tem + 1, sizeof prompt1 - 1);
434 prompt1[sizeof prompt1 - 1] = 0;
435 tem1 = index (prompt1, '\n');
436 if (tem1) *tem1 = 0;
437 /* Fill argstrings with a vector of C strings
438 corresponding to the Lisp strings in visargs. */
439 for (j = 1; j < i; j++)
440 argstrings[j]
441 = EQ (visargs[j], Qnil)
442 ? (unsigned char *) ""
443 : XSTRING (visargs[j])->data;
445 /* Process the format-string in prompt1, putting the output
446 into callint_message. Make callint_message bigger if necessary.
447 We don't use a buffer on the stack, because the contents
448 need to stay stable for a while. */
449 while (1)
451 int nchars = doprnt (callint_message, callint_message_size,
452 prompt1, (char *)0,
453 j - 1, argstrings + 1);
454 if (nchars < callint_message_size)
455 break;
456 callint_message_size *= 2;
457 callint_message
458 = (char *) xrealloc (callint_message, callint_message_size);
461 switch (*tem)
463 case 'a': /* Symbol defined as a function */
464 visargs[i] = Fcompleting_read (build_string (callint_message),
465 Vobarray, Qfboundp, Qt, Qnil, Qnil);
466 /* Passing args[i] directly stimulates compiler bug */
467 teml = visargs[i];
468 args[i] = Fintern (teml, Qnil);
469 break;
471 case 'b': /* Name of existing buffer */
472 args[i] = Fcurrent_buffer ();
473 if (EQ (selected_window, minibuf_window))
474 args[i] = Fother_buffer (args[i], Qnil);
475 args[i] = Fread_buffer (build_string (callint_message), args[i], Qt);
476 break;
478 case 'B': /* Name of buffer, possibly nonexistent */
479 args[i] = Fread_buffer (build_string (callint_message),
480 Fother_buffer (Fcurrent_buffer (), Qnil),
481 Qnil);
482 break;
484 case 'c': /* Character */
485 /* Use message_nolog rather than message1_nolog here,
486 so that nothing bad happens if callint_message is changed
487 within Fread_char (by a timer, for example). */
488 message_nolog ("%s", callint_message);
489 args[i] = Fread_char ();
490 message1_nolog ((char *) 0);
491 /* Passing args[i] directly stimulates compiler bug */
492 teml = args[i];
493 visargs[i] = Fchar_to_string (teml);
494 break;
496 case 'C': /* Command: symbol with interactive function */
497 visargs[i] = Fcompleting_read (build_string (callint_message),
498 Vobarray, Qcommandp, Qt, Qnil, Qnil);
499 /* Passing args[i] directly stimulates compiler bug */
500 teml = visargs[i];
501 args[i] = Fintern (teml, Qnil);
502 break;
504 case 'd': /* Value of point. Does not do I/O. */
505 Fset_marker (point_marker, make_number (PT), Qnil);
506 args[i] = point_marker;
507 /* visargs[i] = Qnil; */
508 varies[i] = 1;
509 break;
511 case 'D': /* Directory name. */
512 args[i] = Fread_file_name (build_string (callint_message), Qnil,
513 current_buffer->directory, Qlambda, Qnil);
514 break;
516 case 'f': /* Existing file name. */
517 args[i] = Fread_file_name (build_string (callint_message),
518 Qnil, Qnil, Qlambda, Qnil);
519 break;
521 case 'F': /* Possibly nonexistent file name. */
522 args[i] = Fread_file_name (build_string (callint_message),
523 Qnil, Qnil, Qnil, Qnil);
524 break;
526 case 'k': /* Key sequence. */
528 int speccount1 = specpdl_ptr - specpdl;
529 specbind (Qcursor_in_echo_area, Qt);
530 args[i] = Fread_key_sequence (build_string (callint_message),
531 Qnil, Qnil, Qnil);
532 unbind_to (speccount1, Qnil);
533 teml = args[i];
534 visargs[i] = Fkey_description (teml);
536 break;
538 case 'K': /* Key sequence to be defined. */
540 int speccount1 = specpdl_ptr - specpdl;
541 specbind (Qcursor_in_echo_area, Qt);
542 args[i] = Fread_key_sequence (build_string (callint_message),
543 Qnil, Qt, Qnil);
544 teml = args[i];
545 visargs[i] = Fkey_description (teml);
546 unbind_to (speccount1, Qnil);
548 break;
550 case 'e': /* The invoking event. */
551 if (next_event >= key_count)
552 error ("%s must be bound to an event with parameters",
553 (SYMBOLP (function)
554 ? (char *) XSYMBOL (function)->name->data
555 : "command"));
556 args[i] = XVECTOR (keys)->contents[next_event++];
557 varies[i] = -1;
559 /* Find the next parameterized event. */
560 while (next_event < key_count
561 && ! (EVENT_HAS_PARAMETERS
562 (XVECTOR (keys)->contents[next_event])))
563 next_event++;
565 break;
567 case 'm': /* Value of mark. Does not do I/O. */
568 check_mark ();
569 /* visargs[i] = Qnil; */
570 args[i] = current_buffer->mark;
571 varies[i] = 2;
572 break;
574 case 'N': /* Prefix arg, else number from minibuffer */
575 if (!NILP (prefix_arg))
576 goto have_prefix_arg;
577 case 'n': /* Read number from minibuffer. */
579 int first = 1;
582 Lisp_Object tem;
583 if (! first)
585 message ("Please enter a number.");
586 sit_for (1, 0, 0, 0);
588 first = 0;
590 tem = Fread_from_minibuffer (build_string (callint_message),
591 Qnil, Qnil, Qnil, Qnil);
592 if (! STRINGP (tem) || XSTRING (tem)->size == 0)
593 args[i] = Qnil;
594 else
595 args[i] = Fread (tem);
597 while (! NUMBERP (args[i]));
599 visargs[i] = last_minibuf_string;
600 break;
602 case 'P': /* Prefix arg in raw form. Does no I/O. */
603 args[i] = prefix_arg;
604 /* visargs[i] = Qnil; */
605 varies[i] = -1;
606 break;
608 case 'p': /* Prefix arg converted to number. No I/O. */
609 have_prefix_arg:
610 args[i] = Fprefix_numeric_value (prefix_arg);
611 /* visargs[i] = Qnil; */
612 varies[i] = -1;
613 break;
615 case 'r': /* Region, point and mark as 2 args. */
616 check_mark ();
617 Fset_marker (point_marker, make_number (PT), Qnil);
618 /* visargs[i+1] = Qnil; */
619 foo = marker_position (current_buffer->mark);
620 /* visargs[i] = Qnil; */
621 args[i] = PT < foo ? point_marker : current_buffer->mark;
622 varies[i] = 3;
623 args[++i] = PT > foo ? point_marker : current_buffer->mark;
624 varies[i] = 4;
625 break;
627 case 's': /* String read via minibuffer. */
628 args[i] = Fread_string (build_string (callint_message), Qnil, Qnil);
629 break;
631 case 'S': /* Any symbol. */
632 visargs[i] = Fread_string (build_string (callint_message),
633 Qnil, Qnil);
634 /* Passing args[i] directly stimulates compiler bug */
635 teml = visargs[i];
636 args[i] = Fintern (teml, Qnil);
637 break;
639 case 'v': /* Variable name: symbol that is
640 user-variable-p. */
641 args[i] = Fread_variable (build_string (callint_message));
642 visargs[i] = last_minibuf_string;
643 break;
645 case 'x': /* Lisp expression read but not evaluated */
646 args[i] = Fread_minibuffer (build_string (callint_message), Qnil);
647 visargs[i] = last_minibuf_string;
648 break;
650 case 'X': /* Lisp expression read and evaluated */
651 args[i] = Feval_minibuffer (build_string (callint_message), Qnil);
652 visargs[i] = last_minibuf_string;
653 break;
655 /* We have a case for `+' so we get an error
656 if anyone tries to define one here. */
657 case '+':
658 default:
659 error ("Invalid control letter `%c' (%03o) in interactive calling string",
660 *tem, *tem);
663 if (varies[i] == 0)
664 arg_from_tty = 1;
666 if (NILP (visargs[i]) && STRINGP (args[i]))
667 visargs[i] = args[i];
669 tem = (unsigned char *) index (tem, '\n');
670 if (tem) tem++;
671 else tem = (unsigned char *) "";
673 unbind_to (speccount, Qnil);
675 QUIT;
677 args[0] = function;
679 if (arg_from_tty || !NILP (record_flag))
681 visargs[0] = function;
682 for (i = 1; i < count + 1; i++)
684 if (varies[i] > 0)
685 visargs[i] = Fcons (intern (callint_argfuns[varies[i]]), Qnil);
686 else
687 visargs[i] = quotify_arg (args[i]);
689 Vcommand_history = Fcons (Flist (count + 1, visargs),
690 Vcommand_history);
693 /* If we used a marker to hold point, mark, or an end of the region,
694 temporarily, convert it to an integer now. */
695 for (i = 1; i <= count; i++)
696 if (varies[i] >= 1 && varies[i] <= 4)
697 XSETINT (args[i], marker_position (args[i]));
699 single_kboard_state ();
702 Lisp_Object val;
703 specbind (Qcommand_debug_status, Qnil);
705 val = Ffuncall (count + 1, args);
706 UNGCPRO;
707 return unbind_to (speccount, val);
711 DEFUN ("prefix-numeric-value", Fprefix_numeric_value, Sprefix_numeric_value,
712 1, 1, 0,
713 "Return numeric meaning of raw prefix argument RAW.\n\
714 A raw prefix argument is what you get from `(interactive \"P\")'.\n\
715 Its numeric meaning is what you would get from `(interactive \"p\")'.")
716 (raw)
717 Lisp_Object raw;
719 Lisp_Object val;
721 if (NILP (raw))
722 XSETFASTINT (val, 1);
723 else if (EQ (raw, Qminus))
724 XSETINT (val, -1);
725 else if (CONSP (raw) && INTEGERP (XCONS (raw)->car))
726 XSETINT (val, XINT (XCONS (raw)->car));
727 else if (INTEGERP (raw))
728 val = raw;
729 else
730 XSETFASTINT (val, 1);
732 return val;
735 syms_of_callint ()
737 point_marker = Fmake_marker ();
738 staticpro (&point_marker);
740 preserved_fns = Fcons (intern ("region-beginning"),
741 Fcons (intern ("region-end"),
742 Fcons (intern ("point"),
743 Fcons (intern ("mark"), Qnil))));
744 staticpro (&preserved_fns);
746 Qlist = intern ("list");
747 staticpro (&Qlist);
748 Qlet = intern ("let");
749 staticpro (&Qlet);
750 Qletx = intern ("let*");
751 staticpro (&Qletx);
752 Qsave_excursion = intern ("save-excursion");
753 staticpro (&Qsave_excursion);
755 Qminus = intern ("-");
756 staticpro (&Qminus);
758 Qplus = intern ("+");
759 staticpro (&Qplus);
761 Qcall_interactively = intern ("call-interactively");
762 staticpro (&Qcall_interactively);
764 Qcommand_debug_status = intern ("command-debug-status");
765 staticpro (&Qcommand_debug_status);
767 Qenable_recursive_minibuffers = intern ("enable-recursive-minibuffers");
768 staticpro (&Qenable_recursive_minibuffers);
770 Qmouse_leave_buffer_hook = intern ("mouse-leave-buffer-hook");
771 staticpro (&Qmouse_leave_buffer_hook);
773 callint_message_size = 100;
774 callint_message = (char *) xmalloc (callint_message_size);
777 DEFVAR_KBOARD ("prefix-arg", Vprefix_arg,
778 "The value of the prefix argument for the next editing command.\n\
779 It may be a number, or the symbol `-' for just a minus sign as arg,\n\
780 or a list whose car is a number for just one or more C-U's\n\
781 or nil if no argument has been specified.\n\
783 You cannot examine this variable to find the argument for this command\n\
784 since it has been set to nil by the time you can look.\n\
785 Instead, you should use the variable `current-prefix-arg', although\n\
786 normally commands can get this prefix argument with (interactive \"P\").");
788 DEFVAR_LISP ("current-prefix-arg", &Vcurrent_prefix_arg,
789 "The value of the prefix argument for this editing command.\n\
790 It may be a number, or the symbol `-' for just a minus sign as arg,\n\
791 or a list whose car is a number for just one or more C-U's\n\
792 or nil if no argument has been specified.\n\
793 This is what `(interactive \"P\")' returns.");
794 Vcurrent_prefix_arg = Qnil;
796 DEFVAR_LISP ("command-history", &Vcommand_history,
797 "List of recent commands that read arguments from terminal.\n\
798 Each command is represented as a form to evaluate.");
799 Vcommand_history = Qnil;
801 DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status,
802 "Debugging status of current interactive command.\n\
803 Bound each time `call-interactively' is called;\n\
804 may be set by the debugger as a reminder for itself.");
805 Vcommand_debug_status = Qnil;
807 DEFVAR_LISP ("mark-even-if-inactive", &Vmark_even_if_inactive,
808 "*Non-nil means you can use the mark even when inactive.\n\
809 This option makes a difference in Transient Mark mode.\n\
810 When the option is non-nil, deactivation of the mark\n\
811 turns off region highlighting, but commands that use the mark\n\
812 behave as if the mark were still active.");
813 Vmark_even_if_inactive = Qnil;
815 DEFVAR_LISP ("mouse-leave-buffer-hook", &Vmouse_leave_buffer_hook,
816 "Hook to run when about to switch windows with a mouse command.\n\
817 Its purpose is to give temporary modes such as Isearch mode\n\
818 a way to turn themselves off when a mouse command switches windows.");
819 Vmouse_leave_buffer_hook = Qnil;
821 defsubr (&Sinteractive);
822 defsubr (&Scall_interactively);
823 defsubr (&Sprefix_numeric_value);