comparison src/callint.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 9ad43877534d
children 2c611d1463a6
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
81 81
82 /* ARGSUSED */ 82 /* ARGSUSED */
83 DEFUN ("interactive", Finteractive, 0, UNEVALLED, 0, /* 83 DEFUN ("interactive", Finteractive, 0, UNEVALLED, 0, /*
84 Specify a way of parsing arguments for interactive use of a function. 84 Specify a way of parsing arguments for interactive use of a function.
85 For example, write 85 For example, write
86 (defun foo (arg) \"Doc string\" (interactive \"p\") ...use arg...) 86 (defun foo (arg) "Doc string" (interactive "p") ...use arg...)
87 to make ARG be the prefix argument when `foo' is called as a command. 87 to make ARG be the prefix argument when `foo' is called as a command.
88 The \"call\" to `interactive' is actually a declaration rather than a function; 88 The "call" to `interactive' is actually a declaration rather than a function;
89 it tells `call-interactively' how to read arguments 89 it tells `call-interactively' how to read arguments
90 to pass to the function. 90 to pass to the function.
91 When actually called, `interactive' just returns nil. 91 When actually called, `interactive' just returns nil.
92 92
93 The argument of `interactive' is usually a string containing a code letter 93 The argument of `interactive' is usually a string containing a code letter
192 { 192 {
193 Lisp_Object s = make_string (prompt_start, prompt_length); 193 Lisp_Object s = make_string (prompt_start, prompt_length);
194 struct gcpro gcpro1; 194 struct gcpro gcpro1;
195 195
196 /* Fformat no longer smashes its arg vector, so no need to copy it. */ 196 /* Fformat no longer smashes its arg vector, so no need to copy it. */
197 197
198 if (!strchr ((char *) XSTRING_DATA (s), '%')) 198 if (!strchr ((char *) XSTRING_DATA (s), '%'))
199 return s; 199 return s;
200 GCPRO1 (s); 200 GCPRO1 (s);
201 RETURN_UNGCPRO (emacs_doprnt_string_lisp (0, s, 0, nargs, args)); 201 RETURN_UNGCPRO (emacs_doprnt_string_lisp (0, s, 0, nargs, args));
202 } 202 }
370 Lisp_Object elt; 370 Lisp_Object elt;
371 elt = Fcar (intail); 371 elt = Fcar (intail);
372 if (CONSP (elt)) 372 if (CONSP (elt))
373 { 373 {
374 Lisp_Object eltcar = Fcar (elt); 374 Lisp_Object eltcar = Fcar (elt);
375 if (EQ (eltcar, Qpoint) 375 if (EQ (eltcar, Qpoint) ||
376 || EQ (eltcar, Qmark) 376 EQ (eltcar, Qmark) ||
377 || EQ (eltcar, Qregion_beginning) 377 EQ (eltcar, Qregion_beginning) ||
378 || EQ (eltcar, Qregion_end)) 378 EQ (eltcar, Qregion_end))
379 Fsetcar (valtail, Fcar (intail)); 379 Fsetcar (valtail, Fcar (intail));
380 } 380 }
381 } 381 }
382 } 382 }
383 } 383 }
418 418
419 for (;;) 419 for (;;)
420 { 420 {
421 if (STRINGP (specs)) 421 if (STRINGP (specs))
422 prompt_data = (CONST char *) XSTRING_DATA (specs); 422 prompt_data = (CONST char *) XSTRING_DATA (specs);
423 423
424 if (prompt_data[prompt_index] == '+') 424 if (prompt_data[prompt_index] == '+')
425 error ("`+' is not used in `interactive' for ordinary commands"); 425 error ("`+' is not used in `interactive' for ordinary commands");
426 else if (prompt_data[prompt_index] == '*') 426 else if (prompt_data[prompt_index] == '*')
427 { 427 {
428 prompt_index++; 428 prompt_index++;
441 event = extract_this_command_keys_nth_mouse_event (0); 441 event = extract_this_command_keys_nth_mouse_event (0);
442 #else 442 #else
443 /* Doesn't work; see below */ 443 /* Doesn't work; see below */
444 event = Vcurrent_mouse_event; 444 event = Vcurrent_mouse_event;
445 #endif 445 #endif
446 if (! NILP (event)) 446 if (! NILP (event))
447 { 447 {
448 Lisp_Object window = Fevent_window (event); 448 Lisp_Object window = Fevent_window (event);
449 if (!NILP (window)) 449 if (!NILP (window))
450 { 450 {
451 if (MINI_WINDOW_P (XWINDOW (window)) 451 if (MINI_WINDOW_P (XWINDOW (window))
531 int alloca_size = (1 /* function to call */ 531 int alloca_size = (1 /* function to call */
532 + argcount /* actual arguments */ 532 + argcount /* actual arguments */
533 + argcount /* visargs */ 533 + argcount /* visargs */
534 + argcount /* varies */ 534 + argcount /* varies */
535 ); 535 );
536 Lisp_Object *args 536 Lisp_Object *args = alloca_array (Lisp_Object, alloca_size) + 1;
537 = (((Lisp_Object *) alloca (sizeof (Lisp_Object) * alloca_size))
538 + 1);
539 /* visargs is an array of either Qnil or user-friendlier versions (often 537 /* visargs is an array of either Qnil or user-friendlier versions (often
540 * strings) of previous arguments, to use in prompts for succesive 538 * strings) of previous arguments, to use in prompts for successive
541 * arguments. ("Often strings" because emacs didn't used to have 539 * arguments. ("Often strings" because emacs didn't used to have
542 * format %S and prin1-to-string.) */ 540 * format %S and prin1-to-string.) */
543 Lisp_Object *visargs = args + argcount; 541 Lisp_Object *visargs = args + argcount;
544 /* If varies[i] is non-null, the i'th argument shouldn't just have 542 /* If varies[i] is non-null, the i'th argument shouldn't just have
545 its value in this call quoted in the command history. It should be 543 its value in this call quoted in the command history. It should be
562 for (argnum = 0; ; argnum++) 560 for (argnum = 0; ; argnum++)
563 { 561 {
564 CONST char *prompt_start = prompt_data + prompt_index + 1; 562 CONST char *prompt_start = prompt_data + prompt_index + 1;
565 CONST char *prompt_limit = (CONST char *) strchr (prompt_start, '\n'); 563 CONST char *prompt_limit = (CONST char *) strchr (prompt_start, '\n');
566 int prompt_length; 564 int prompt_length;
567 prompt_length = ((prompt_limit) 565 prompt_length = ((prompt_limit)
568 ? (prompt_limit - prompt_start) 566 ? (prompt_limit - prompt_start)
569 : strlen (prompt_start)); 567 : strlen (prompt_start));
570 if (prompt_limit && prompt_limit[1] == 0) 568 if (prompt_limit && prompt_limit[1] == 0)
571 { 569 {
572 prompt_limit = 0; /* "sfoo:\n" -- strip tailing return */ 570 prompt_limit = 0; /* "sfoo:\n" -- strip tailing return */
813 */ 811 */
814 tem = Fintern (tem, Qnil); 812 tem = Fintern (tem, Qnil);
815 args[argnum] = tem; 813 args[argnum] = tem;
816 if (string_length (XSYMBOL (tem)->name) > 0) 814 if (string_length (XSYMBOL (tem)->name) > 0)
817 /* Don't accept the empty-named symbol. If the loser 815 /* Don't accept the empty-named symbol. If the loser
818 really wants this s/he can call completing-read 816 really wants this s/he can call completing-read
819 directly */ 817 directly */
820 break; 818 break;
821 } 819 }
822 #endif /* 1 */ 820 #endif /* 1 */
823 arg_from_tty = 1; 821 arg_from_tty = 1;
850 #ifdef MULE 848 #ifdef MULE
851 if (NILP (prefix)) 849 if (NILP (prefix))
852 { 850 {
853 args[argnum] = Qnil; 851 args[argnum] = Qnil;
854 } 852 }
855 else 853 else
856 { 854 {
857 args[argnum] = 855 args[argnum] =
858 call1 (Qread_non_nil_coding_system, PROMPT ()); 856 call1 (Qread_non_nil_coding_system, PROMPT ());
859 arg_from_tty = 1; 857 arg_from_tty = 1;
860 } 858 }
900 898
901 if (EQ (record_flag, Qlambda)) 899 if (EQ (record_flag, Qlambda))
902 { 900 {
903 RETURN_UNGCPRO (Flist (argcount, args)); 901 RETURN_UNGCPRO (Flist (argcount, args));
904 } 902 }
905 903
906 if (arg_from_tty || !NILP (record_flag)) 904 if (arg_from_tty || !NILP (record_flag))
907 { 905 {
908 /* Reuse visargs as a temporary for constructing the command history */ 906 /* Reuse visargs as a temporary for constructing the command history */
909 for (argnum = 0; argnum < argcount; argnum++) 907 for (argnum = 0; argnum < argcount; argnum++)
910 { 908 {
933 } 931 }
934 } 932 }
935 933
936 DEFUN ("prefix-numeric-value", Fprefix_numeric_value, 1, 1, 0, /* 934 DEFUN ("prefix-numeric-value", Fprefix_numeric_value, 1, 1, 0, /*
937 Return numeric meaning of raw prefix argument ARG. 935 Return numeric meaning of raw prefix argument ARG.
938 A raw prefix argument is what you get from `(interactive \"P\")'. 936 A raw prefix argument is what you get from `(interactive "P")'.
939 Its numeric meaning is what you would get from `(interactive \"p\")'. 937 Its numeric meaning is what you would get from `(interactive "p")'.
940 */ 938 */
941 (raw)) 939 (raw))
942 { 940 {
943 int val;
944
945 if (NILP (raw)) 941 if (NILP (raw))
946 val = 1; 942 return make_int (1);
947 else if (EQ (raw, Qminus)) 943 if (EQ (raw, Qminus))
948 val = -1; 944 return make_int (-1);
949 else if (INTP (raw)) 945 if (INTP (raw))
950 val = XINT (raw); 946 return raw;
951 else if (CONSP (raw) && INTP (XCAR (raw))) 947 if (CONSP (raw) && INTP (XCAR (raw)))
952 val = XINT (XCAR (raw)); 948 return XCAR (raw);
953 else 949
954 val = 1; 950 return make_int (1);
955
956 return make_int (val);
957
958 } 951 }
959 952
960 void 953 void
961 syms_of_callint (void) 954 syms_of_callint (void)
962 { 955 {
1001 DEFVAR_LISP ("current-prefix-arg", &Vcurrent_prefix_arg /* 994 DEFVAR_LISP ("current-prefix-arg", &Vcurrent_prefix_arg /*
1002 The value of the prefix argument for this editing command. 995 The value of the prefix argument for this editing command.
1003 It may be a number, or the symbol `-' for just a minus sign as arg, 996 It may be a number, or the symbol `-' for just a minus sign as arg,
1004 or a list whose car is a number for just one or more C-U's 997 or a list whose car is a number for just one or more C-U's
1005 or nil if no argument has been specified. 998 or nil if no argument has been specified.
1006 This is what `(interactive \"P\")' returns. 999 This is what `(interactive "P")' returns.
1007 */ ); 1000 */ );
1008 Vcurrent_prefix_arg = Qnil; 1001 Vcurrent_prefix_arg = Qnil;
1009 1002
1010 DEFVAR_LISP ("command-history", &Vcommand_history /* 1003 DEFVAR_LISP ("command-history", &Vcommand_history /*
1011 List of recent commands that read arguments from terminal. 1004 List of recent commands that read arguments from terminal.
1019 may be set by the debugger as a reminder for itself. 1012 may be set by the debugger as a reminder for itself.
1020 */ ); 1013 */ );
1021 Vcommand_debug_status = Qnil; 1014 Vcommand_debug_status = Qnil;
1022 1015
1023 #if 0 /* FSFmacs */ 1016 #if 0 /* FSFmacs */
1024 xxDEFVAR_LISP ("mark-even-if-inactive", &Vmark_even_if_inactive /* 1017 xxDEFVAR_LISP ("mark-even-if-inactive", &Vmark_even_if_inactive /*
1025 *Non-nil means you can use the mark even when inactive. 1018 *Non-nil means you can use the mark even when inactive.
1026 This option makes a difference in Transient Mark mode. 1019 This option makes a difference in Transient Mark mode.
1027 When the option is non-nil, deactivation of the mark 1020 When the option is non-nil, deactivation of the mark
1028 turns off region highlighting, but commands that use the mark 1021 turns off region highlighting, but commands that use the mark
1029 behave as if the mark were still active. 1022 behave as if the mark were still active.