home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / src / callint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-14  |  23.2 KB  |  732 lines

  1. /* Call a Lisp function interactively.
  2.    Copyright (C) 1985-1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  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.
  10.  
  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.
  15.  
  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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include "config.h"
  22. #include "lisp.h"
  23. #include "buffer.h"
  24. #include "commands.h"
  25. #include "window.h"
  26.  
  27. extern int num_input_chars;
  28.  
  29. Lisp_Object Vprefix_arg, Vcurrent_prefix_arg;
  30. Lisp_Object Qcall_interactively;
  31. Lisp_Object Vcommand_history;
  32.  
  33. Lisp_Object Vcommand_debug_status, Qcommand_debug_status;
  34. Lisp_Object Qenable_recursive_minibuffers;
  35.  
  36. Lisp_Object Qminus;
  37. Lisp_Object Qcurrent_prefix_arg;
  38.  
  39. Lisp_Object Quser_variable_p;
  40. Lisp_Object Qread_from_minibuffer;
  41. Lisp_Object Qread_file_name;
  42. Lisp_Object Qread_directory_name;
  43. Lisp_Object Qcompleting_read;
  44. Lisp_Object Qread_buffer;
  45. Lisp_Object Qread_function;
  46. Lisp_Object Qread_variable;
  47. Lisp_Object Qread_minibuffer;
  48. Lisp_Object Qread_command;
  49. Lisp_Object Qread_number;
  50. Lisp_Object Qread_string;
  51.  
  52.  
  53. extern Lisp_Object Qpoint, Qmark, Qregion_beginning, Qregion_end;
  54.  
  55. extern Lisp_Object ml_apply ();
  56.  
  57. /* This comment supplies the doc string for interactive,
  58.    for make-docfile to see.  We cannot put this in the real DEFUN
  59.    due to limits in the Unix cpp.
  60.  
  61. DEFUN ("interactive", Ffoo, Sfoo, 0, 0, 0,
  62.  "Specify a way of parsing arguments for interactive use of a function.\n\
  63. For example, write\n\
  64.   (defun foo (arg) \"Doc string\" (interactive \"p\") ...use arg...)\n\
  65. to make ARG be the prefix argument when `foo' is called as a command.\n\
  66. The \"call\" to `interactive' is actually a declaration rather than a function;\n\
  67.  it tells `call-interactively' how to read arguments\n\
  68.  to pass to the function.\n\
  69. When actually called, `interactive' just returns nil.\n\
  70. \n\
  71. The argument of `interactive' is usually a string containing a code letter\n\
  72.  followed by a prompt.  (Some code letters do not use I/O to get\n\
  73.  the argument and do not need prompts.)  To prompt for multiple arguments,\n\
  74.  give a code letter, its prompt, a newline, and another code letter, etc.\n\
  75.  Prompts are passed to format, and may use % escapes to print the\n\
  76.  arguments that have already been read.\n\
  77. If the argument is not a string, it is evaluated to get a list of\n\
  78.  arguments to pass to the function.\n\
  79. Just `(interactive)' means pass no args when calling interactively.\n\
  80. \nCode letters available are:\n\
  81. a -- Function name: symbol with a function definition.\n\
  82. b -- Name of existing buffer.\n\
  83. B -- Name of buffer, possibly nonexistent.\n\
  84. c -- Character.\n\
  85. C -- Command name: symbol with interactive function definition.\n\
  86. d -- Value of point as number.  Does not do I/O.\n\
  87. D -- Directory name.\n\
  88. e -- Last mouse event.\n\
  89. f -- Existing file name.\n\
  90. F -- Possibly nonexistent file name.\n\
  91. k -- Key sequence (a vector of events).\n\
  92. m -- Value of mark as number.  Does not do I/O.\n\
  93. n -- Number read using minibuffer.\n\
  94. N -- Prefix arg converted to number, or if none, do like code `n'.\n\
  95. p -- Prefix arg converted to number.  Does not do I/O.\n\
  96. P -- Prefix arg in raw form.  Does not do I/O.\n\
  97. r -- Region: point and mark as 2 numeric args, smallest first.  Does no I/O.\n\
  98. s -- Any string.\n\
  99. S -- Any symbol.\n\
  100. v -- Variable name: symbol that is user-variable-p.\n\
  101. x -- Lisp expression read but not evaluated.\n\
  102. X -- Lisp expression read and evaluated.\n\
  103. In addition, if the string begins with `*'\n\
  104.  then an error is signaled if the buffer is read-only.\n\
  105.  This happens before reading any arguments.\n\
  106. If the string begins with `@', then the window the mouse is over is selected\n\
  107.  before anything else is done.  You may use both `@' and `*';\n\
  108. they are processed in the order that they appear."
  109. */
  110.  
  111. /* ARGSUSED */
  112. DEFUN ("interactive", Finteractive, Sinteractive, 0, UNEVALLED, 0,
  113.   0 /* See immediately above */)
  114.   (args)
  115.      Lisp_Object args;
  116. {
  117.   return Qnil;
  118. }
  119.  
  120. /* Quotify EXP: if EXP is constant, return it.
  121.    If EXP is not constant, return (quote EXP).  */
  122. static Lisp_Object
  123. quotify_arg (exp)
  124.      register Lisp_Object exp;
  125. {
  126.   if (!FIXNUMP (exp) && !STRINGP (exp)
  127.       && !NILP (exp) && !EQ (exp, Qt))
  128.     return Fcons (Qquote, Fcons (exp, Qnil));
  129.  
  130.   return exp;
  131. }
  132.  
  133. /* Modify EXP by quotifying each element (except the first).  */
  134. static Lisp_Object
  135. quotify_args (exp)
  136.      Lisp_Object exp;
  137. {
  138.   register Lisp_Object tail;
  139.   register struct Lisp_Cons *ptr;
  140.   for (tail = exp; CONSP (tail); tail = ptr->cdr)
  141.     {
  142.       ptr = XCONS (tail);
  143.       ptr->car = quotify_arg (ptr->car);
  144.     }
  145.   return exp;
  146. }
  147.  
  148. static int
  149. check_mark ()
  150. {
  151.   Lisp_Object tem;
  152.   if (zmacs_regions && !zmacs_region_active_p)
  153.     error ("The region is not active now");
  154.   tem = Fmarker_buffer (current_buffer->mark);
  155.   if (NILP (tem) || (XBUFFER (tem) != current_buffer))
  156.     error ("The mark is not set now");
  157.   return (marker_position (current_buffer->mark));
  158. }
  159.  
  160. Lisp_Object Vcurrent_mouse_event;
  161.  
  162. static Lisp_Object
  163. callint_prompt (const char *prompt_start, int prompt_length,
  164.                 const Lisp_Object *args, int nargs)
  165. {
  166.   Lisp_Object s = make_string (prompt_start, prompt_length);
  167.   Lisp_Object *xargs;
  168.   struct gcpro gcpro1;
  169.  
  170.   if (!strchr ((char *) XSTRING (s)->data, '%'))
  171.     return (s);
  172.  
  173.   /* Oh fuck!  Fformat smashes its arg vector!  Have to copy it */
  174.   xargs = (Lisp_Object *) alloca ((nargs + 1) * sizeof (Lisp_Object));
  175.   memcpy ((char *) xargs, (char *) args, (nargs + 1) * sizeof (Lisp_Object));
  176.   xargs[0] = s;
  177.   GCPRO1 (*xargs);
  178.   gcpro1.nvars = (nargs + 1);
  179.   RETURN_UNGCPRO (Fformat (nargs + 1, xargs));
  180. }
  181.  
  182. DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 2, 0,
  183.   "Call FUNCTION, reading args according to its interactive calling specs.\n\
  184. The function contains a specification of how to do the argument reading.\n\
  185. In the case of user-defined functions, this is specified by placing a call\n\
  186. to the function `interactive' at the top level of the function body.\n\
  187. See `interactive'.\n\
  188. \n\
  189. If optional second arg RECORD-FLAG is `t' then unconditionally put this\n\
  190. ommand in the command-history.  Otherwise, this is done only if an arg is\n\
  191. read using the minibuffer.")
  192.   (function, record_flag)
  193.      Lisp_Object function, record_flag;
  194. {
  195.   int speccount = specpdl_depth;
  196.   /* Save this now, since use of minibuffer will clobber it. */
  197.   Lisp_Object prefix = Vcurrent_prefix_arg;
  198.  
  199.   Lisp_Object fun;
  200.   Lisp_Object specs = Qnil;
  201.   /* If SPECS is a string, we reset prompt_data to XSTRING (specs)->data
  202.    *  every time a GC might have occurred */
  203.   char *prompt_data = 0;
  204.   int prompt_index = 0;
  205.   int argcount;
  206.   int set_zmacs_region_stays = 0;
  207.  
  208.  retry:
  209.  
  210.   fun = indirect_function (function, 1);
  211.  
  212.   /* Decode the kind of function.  Either handle it and return,
  213.      or go to `lose' if not interactive, or go to `retry'
  214.      to specify a different function, or set either PROMPT_DATA or SPECS. */
  215.  
  216.   if (SUBRP (fun))
  217.     {
  218.       prompt_data = XSUBR (fun)->prompt;
  219.       if (!prompt_data)
  220.     {
  221.     lose:
  222.       function = wrong_type_argument (Qcommandp, function);
  223.       goto retry;
  224.     }
  225.     }
  226.   else if (COMPILEDP (fun))
  227.     {
  228.       if (XVECTOR (fun)->size <= COMPILED_INTERACTIVE)
  229.     goto lose;
  230.       specs = XVECTOR (fun)->contents[COMPILED_INTERACTIVE];
  231.     }
  232.   else if (!CONSP (fun))
  233.     goto lose;
  234.   else
  235.     {
  236.       Lisp_Object funcar = Fcar (fun);
  237.  
  238.       if (EQ (funcar, Qautoload))
  239.     {
  240.       struct gcpro gcpro1, gcpro2;
  241.       GCPRO2 (function, prefix);
  242.       do_autoload (fun, function);
  243.       UNGCPRO;
  244.       goto retry;
  245.     }
  246.       else if (EQ (funcar, Qlambda))
  247.     {
  248.       specs = Fassq (Qinteractive, Fcdr (Fcdr (fun)));
  249.       if (NILP (specs))
  250.         goto lose;
  251.       specs = Fcar (Fcdr (specs));
  252.     }
  253.       else if (EQ (funcar, Qmocklisp))
  254.     return ml_apply (fun, Qinteractive);
  255.       else
  256.     goto lose;
  257.     }
  258.  
  259.   /* If either specs or prompt_data is set to a string, use it.  */
  260.   if (!STRINGP (specs) && prompt_data == 0)
  261.     {
  262.       struct gcpro gcpro1, gcpro2;
  263.       int i = num_input_chars;
  264.       GCPRO2 (function, specs);
  265.       specs = Feval (specs);
  266.       if (EQ (record_flag, Qlambda))
  267.       {
  268.         UNGCPRO;
  269.         return (specs);
  270.       }
  271.       if (!NILP (record_flag) || i != num_input_chars)
  272.     Vcommand_history
  273.       = Fcons (Fcons (function, quotify_args (Fcopy_sequence (specs))),
  274.            Vcommand_history);
  275.       RETURN_UNGCPRO (apply1 (fun, specs));
  276.     }
  277.  
  278.   /* Here if function specifies a string to control parsing the defaults */
  279.  
  280.   /* Handle special starting chars `*' and `@' and `_'.  */
  281.   prompt_index = 0;
  282.   if (STRINGP (specs)) prompt_data = (char *) XSTRING (specs)->data;
  283.   while (1)
  284.     {
  285.       if (prompt_data[prompt_index] == '*')
  286.     {
  287.       prompt_index++;
  288.       if (!NILP (current_buffer->read_only))
  289.         Fbarf_if_buffer_read_only ();
  290.     }
  291.       else if (prompt_data[prompt_index] == '@')
  292.     {
  293.       prompt_index++;
  294.       if (! NILP (Vcurrent_mouse_event)) 
  295.           {
  296.         Lisp_Object window = Fevent_window (Vcurrent_mouse_event);
  297.         if (!NILP (window))
  298.           Fselect_window (window);
  299.       }
  300.     }
  301.       else if (prompt_data[prompt_index] == '_')
  302.     {
  303.       prompt_index++;
  304.           set_zmacs_region_stays = 1;
  305.     }
  306.       else
  307.         break;
  308.       if (STRINGP (specs)) prompt_data = (char *) XSTRING (specs)->data;
  309.     }
  310.  
  311.   /* Count the number of arguments the interactive spec would have
  312.      us give to the function.  */
  313.   argcount = 0;
  314.   {
  315.     const char *tem;
  316.     for (tem = prompt_data + prompt_index; *tem; )
  317.     {
  318.       /* 'r' specifications ("point and mark as 2 numeric args")
  319.      produce *two* arguments.  */
  320.       if (*tem == 'r')
  321.         argcount += 2;
  322.       else
  323.         argcount += 1;
  324.       tem = (char *) strchr (tem + 1, '\n');
  325.       if (!tem)
  326.         break;
  327.       tem++;
  328.     }
  329.   }
  330.  
  331.   if (argcount == 0)
  332.   {
  333.     /* Interactive function or no arguments; just call it */
  334.     if (EQ (record_flag, Qlambda))
  335.       return (Qnil);
  336.     if (!NILP (record_flag))
  337.     {
  338.       Vcommand_history = Fcons (list1 (function), Vcommand_history);
  339.     }
  340.     specbind (Qcommand_debug_status, Qnil);
  341.     return (unbind_to (speccount, call0 (fun)));
  342.   }
  343.  
  344.   {
  345.     Lisp_Object *args
  346.       = (Lisp_Object *) alloca ((argcount + 1) * sizeof (Lisp_Object));
  347.     Lisp_Object *visargs
  348.       = (Lisp_Object *) alloca ((argcount + 1) * sizeof (Lisp_Object));
  349.     /* If varies[i] is non-null, the i'th argument shouldn't just have
  350.        its value in this call quoted in the command history.  It should be
  351.        recorded as a call to the function named varies[i]]. */
  352.     Lisp_Object *varies
  353.       = (int *) alloca ((argcount + 1) * sizeof (Lisp_Object));
  354.     int arg_from_tty = 0;
  355.     register int argnum;
  356.     struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
  357.  
  358.     for (argnum = 0; argnum < argcount + 1; argnum++)
  359.     {
  360.       args[argnum] = Qnil;
  361.       visargs[argnum] = Qnil;
  362.       varies[argnum] = Qnil;
  363.     }
  364.  
  365.     GCPRO4 (prefix, function, *args, *visargs);
  366.     gcpro3.nvars = (argcount + 1);
  367.     gcpro4.nvars = (argcount + 1);
  368.  
  369.     if (SYMBOLP (function)
  370.         && !NILP (Fget (function, Qenable_recursive_minibuffers)))
  371.       specbind (Qenable_recursive_minibuffers, Qt);
  372.  
  373.     for (argnum = 1; ; argnum++)
  374.     {
  375.       char *prompt_start = prompt_data + prompt_index + 1;
  376.       char *prompt_limit = strchr (prompt_start, '\n');
  377.       int prompt_length;
  378.       if (prompt_limit && prompt_limit[1] == 0)
  379.         prompt_limit = 0;       /* "sfoo:\n" -- strip tailing return */
  380.       prompt_length = ((prompt_limit) 
  381.                        ? (prompt_limit - prompt_start)
  382.                        : strlen (prompt_start));
  383. #define PROMPT() \
  384.     callint_prompt (prompt_start, prompt_length, visargs, argnum)
  385.  
  386.       switch (prompt_data[prompt_index])
  387.       {
  388.       case 'a':                 /* Symbol defined as a function */
  389.         {
  390.           args[argnum] = call1 (Qread_function, PROMPT ());
  391.           visargs[argnum] = Fsymbol_name (args[argnum]);
  392.           arg_from_tty = 1;
  393.           break;
  394.         }
  395.       case 'b':           /* Name of existing buffer */
  396.         {
  397.           Lisp_Object tem = Fcurrent_buffer ();
  398.           if (EQ (selected_window, minibuf_window))
  399.             tem = Fother_buffer (tem, Qnil);
  400.           args[argnum] = call3 (Qread_buffer, PROMPT (), tem, Qt);
  401.           arg_from_tty = 1;
  402.           break;
  403.         }
  404.       case 'B':                 /* Name of buffer, possibly nonexistent */
  405.         {
  406.           args[argnum] = call2 (Qread_buffer, PROMPT (),
  407.                 Fother_buffer (Fcurrent_buffer (), Qnil));
  408.           arg_from_tty = 1;
  409.           break;
  410.         }
  411.       case 'c':                 /* Character */
  412.         {
  413. #if 0
  414.           /* screw this.  redisplay just doesn't notice changes in
  415.          cursor_in_echo_area */
  416.           int speccount = specpdl_depth;
  417.           specbind (Qcursor_in_echo_area, Qt);
  418. #endif
  419.           message ("%s", XSTRING (PROMPT ())->data);
  420.           args[argnum] = (call0 (Qread_char));
  421. #if 0
  422.           unbind_to (speccount, Qnil);
  423. #endif
  424.       /* #### `C-x / a' should not leave the prompt in the minibuffer.
  425.          This isn't the right fix, because (message ...) (read-char)
  426.          shouldn't leave the message there either... */
  427.       message (0);
  428.  
  429.           arg_from_tty = 1;
  430.           break;
  431.         }
  432.       case 'C':                 /* Command: symbol with interactive function */
  433.         {
  434.           args[argnum] = call1 (Qread_command, PROMPT ());
  435.           visargs[argnum] = Fsymbol_name (args[argnum]);
  436.           arg_from_tty = 1;
  437.           break;
  438.         }
  439.       case 'd':                 /* Value of point.  Does not do I/O.  */
  440.         {
  441.           XFASTINT (args[argnum]) = point;
  442.           varies[argnum] = Qpoint;
  443.           break;
  444.         }
  445.       case 'e':
  446.         {
  447.           args[argnum] = Vcurrent_mouse_event;
  448.           break;
  449.         }
  450.       case 'D':                 /* Directory name. */
  451.         {
  452.           args[argnum] = call4 (Qread_directory_name, PROMPT (),
  453.                                 Qnil, /* dir */
  454.                                 current_buffer->directory, /* default */
  455.                                 Qt /* must-match */
  456.                                 );
  457.           arg_from_tty = 1;
  458.           break;
  459.         }
  460.       case 'f':                 /* Existing file name. */
  461.         {
  462.           args[argnum] = call4 (Qread_file_name, PROMPT (),
  463.                                 Qnil, /* dir */
  464.                                 Qnil, /* default */
  465.                                 make_number (0) /* must-match */
  466.                                 );
  467.           arg_from_tty = 1;
  468.           break;
  469.         }
  470.       case 'F':                 /* Possibly nonexistent file name. */
  471.         {
  472.           args[argnum] = call4 (Qread_file_name, PROMPT (),
  473.                                 Qnil, /* dir */
  474.                                 Qnil, /* default */
  475.                                 Qnil /* must-match */
  476.                                 );
  477.           arg_from_tty = 1;
  478.           break;
  479.         }
  480.       case 'k':                 /* Key sequence (vector of events) */
  481.     {
  482.       args[argnum] = Fread_key_sequence (PROMPT ());
  483.       visargs[argnum] = Fkey_description (args[argnum]);
  484.           arg_from_tty = 1;
  485.           break;
  486.         }
  487.  
  488.       case 'm':                 /* Value of mark.  Does not do I/O.  */
  489.         {
  490.           XFASTINT (args[argnum]) = check_mark ();
  491.           varies[argnum] = Qmark;
  492.           break;
  493.         }
  494.       case 'N':                 /* Prefix arg, else number from minibuffer */
  495.         {
  496.           if (!NILP (prefix))
  497.             goto have_prefix_arg;
  498.           else
  499.            goto read_number;
  500.         }
  501.       case 'n':                 /* Read number from minibuffer.  */
  502.         {
  503.         read_number:
  504.       args[argnum] = call2 (Qread_number, PROMPT (), Qt);
  505.       visargs[argnum] = Fprin1_to_string (args[argnum], Qnil);
  506.       /* numbers are too boring to go on command history */
  507.       /* arg_from_tty = 1; */
  508.           break;
  509.         }
  510.       case 'P':                 /* Prefix arg in raw form.  Does no I/O.  */
  511.         {
  512.         have_prefix_arg:
  513.           args[argnum] = prefix;
  514.           break;
  515.         }
  516.       case 'p':                 /* Prefix arg converted to number.  No I/O. */
  517.         {
  518.           args[argnum] = Fprefix_numeric_value (prefix);
  519.           break;
  520.         }
  521.       case 'r':                 /* Region, point and mark as 2 args. */
  522.         {
  523.           int tem = check_mark ();
  524.           XFASTINT (args[argnum]) = ((point < tem) ? point : tem);
  525.           varies[argnum] = Qregion_beginning;
  526.           XFASTINT (args[++argnum]) = ((point > tem) ? point : tem);
  527.           varies[argnum] = Qregion_end;
  528.           break;
  529.         }
  530.       case 's':                 /* String read via minibuffer.  */
  531.         {
  532.           args[argnum] = call1 (Qread_string, PROMPT ());
  533.           arg_from_tty = 1;
  534.           break;
  535.         }
  536.       case 'S':                 /* Any symbol.  */
  537.         {
  538. #if 0  /* Historical crock */
  539.           Lisp_Object tem = intern ("minibuffer-local-ns-map");
  540.           tem = find_symbol_value (tem);
  541.           if (EQ (tem, Qunbound)) tem = Qnil;
  542.           tem = call3 (Qread_from_minibuffer, PROMPT (), Qnil, tem);
  543.           visargs[argnum] = tem;
  544.           args[argnum] = Fintern (tem, Qnil);
  545. #else
  546.           visargs[argnum] = Qnil;
  547.           for (;;)
  548.           {
  549.             Lisp_Object tem = call5 (Qcompleting_read, PROMPT (), Vobarray,
  550.                      Qnil, Qnil,
  551.                      /* nil, or prev attempt */
  552.                      visargs[argnum]);
  553.             visargs[argnum] = tem;
  554.             /* I could use condition-case with this loser, but why bother?
  555.              * tem = Fread (tem); check-symbol-p;
  556.              */
  557.             tem = Fintern (tem, Qnil);
  558.             args[argnum] = tem;
  559.             if (XSYMBOL(tem)->name->size > 0)
  560.               /* Don't accept the empty-named symbol.  If the loser
  561.                  really wants this s/he can call completing-read directly */
  562.               break;
  563.           }
  564. #endif
  565.           arg_from_tty = 1;
  566.           break;
  567.         }
  568.    case 'v':                 /* Variable name: user-variable-p symbol */
  569.         {
  570.           args[argnum] = call1 (Qread_variable, PROMPT ());
  571.           visargs[argnum] = Fsymbol_name (args[argnum]);
  572.           arg_from_tty = 1;
  573.           break;
  574.         }
  575.       case 'x':                 /* Lisp expression read but not evaluated */
  576.         {
  577.           args[argnum] = call1 (Qread_minibuffer, PROMPT ());
  578.           visargs[argnum] = Fprin1_to_string (args[argnum], Qnil);
  579.           arg_from_tty = 1;
  580.           break;
  581.         }
  582.       case 'X':                 /* Lisp expression read and evaluated */
  583.         {
  584.       Lisp_Object tem = call1 (Qread_minibuffer, PROMPT ());
  585.           visargs[argnum] = Fprin1_to_string (tem, Qnil);
  586.       args[argnum] = Feval (tem);
  587.           arg_from_tty = 1;
  588.           break;
  589.         }
  590.       default:
  591.         {
  592.           error ("Invalid `interactive' control letter \"%c\" (#o%03o).",
  593.                  prompt_data[prompt_index],
  594.                  prompt_data[prompt_index]);
  595.         }
  596.       }
  597. #undef PROMPT
  598.  
  599.       if (NILP (visargs[argnum]) && STRINGP (args[argnum]))
  600.     visargs[argnum] = args[argnum];
  601.  
  602.       if (!prompt_limit)
  603.         break;
  604.       if (STRINGP (specs)) prompt_data = (char *) XSTRING (specs)->data;
  605.       prompt_index += prompt_length + 1 + 1; /* +1 to skip spec, +1 for \n */
  606.     }
  607.     unbind_to (speccount, Qnil);
  608.  
  609.     QUIT;
  610.  
  611.     if (EQ (record_flag, Qlambda))
  612.     {
  613.       RETURN_UNGCPRO (Flist (argcount, args + 1));
  614.     }
  615.       
  616.     args[0] = function;
  617.     if (arg_from_tty || !NILP (record_flag))
  618.     {
  619.       visargs[0] = function;
  620.       for (argnum = 1; argnum < argcount + 1; argnum++)
  621.       {
  622.     if (!NILP (varies[argnum]))
  623.       visargs[argnum] = list1 (varies[argnum]);
  624.     else
  625.       visargs[argnum] = quotify_arg (args[argnum]);
  626.       }
  627.       Vcommand_history = Fcons (Flist (argcount + 1, visargs),
  628.                 Vcommand_history);
  629.     }
  630.  
  631.     specbind (Qcommand_debug_status, Qnil);
  632.     fun = Ffuncall (argcount + 1, args);
  633.     UNGCPRO;
  634.     if (set_zmacs_region_stays)
  635.       zmacs_region_stays = 1;
  636.     return (unbind_to (speccount, fun));
  637.   }
  638. }
  639.  
  640.  
  641. DEFUN ("prefix-numeric-value", Fprefix_numeric_value, Sprefix_numeric_value,
  642.   1, 1, 0,
  643.   "Return numeric meaning of raw prefix argument ARG.\n\
  644. A raw prefix argument is what you get from `(interactive \"P\")'.\n\
  645. Its numeric meaning is what you would get from `(interactive \"p\")'.")
  646.   (raw)
  647.      Lisp_Object raw;
  648. {
  649.   Lisp_Object val;
  650.   
  651.   /* Tag val as an integer, so the rest of the assignments
  652.      may use XSETINT.  */
  653.   XFASTINT (val) = 0;
  654.   if (NILP (raw))
  655.     XFASTINT (val) = 1;
  656.   else if (SYMBOLP (raw))
  657.     XSETINT (val, -1);
  658.   else if (CONSP (raw))
  659.     XSETINT (val, XINT (XCONS (raw)->car));
  660.   else if (FIXNUMP (raw))
  661.     val = raw;
  662.   else
  663.     XFASTINT (val) = 1;
  664.  
  665.   return val;
  666. }
  667.  
  668. Lisp_Object Qminus;
  669. Lisp_Object Qcurrent_prefix_arg;
  670.  
  671. void
  672. syms_of_callint ()
  673. {
  674.   defsymbol (&Qminus, "-");
  675.   defsymbol (&Qcall_interactively, "call-interactively");
  676.   defsymbol (&Qread_from_minibuffer, "read-from-minibuffer");
  677.   defsymbol (&Qcompleting_read, "completing-read");
  678.   defsymbol (&Qread_file_name, "read-file-name");
  679.   defsymbol (&Qread_directory_name, "read-directory-name");
  680.   defsymbol (&Qread_string, "read-string");
  681.   defsymbol (&Qread_buffer, "read-buffer");
  682.   defsymbol (&Qread_variable, "read-variable");
  683.   defsymbol (&Qread_function, "read-function");
  684.   defsymbol (&Qread_command, "read-command");
  685.   defsymbol (&Qread_number, "read-number");
  686.   defsymbol (&Qread_minibuffer, "read-minibuffer");
  687.   defsymbol (&Qcommand_debug_status, "command-debug-status");
  688.   defsymbol (&Qenable_recursive_minibuffers, "enable-recursive-minibuffers");
  689.   defsymbol (&Quser_variable_p, "user-variable-p");
  690.   defsymbol (&Qcurrent_prefix_arg, "current-prefix-arg");
  691.  
  692.   DEFVAR_LISP ("prefix-arg", &Vprefix_arg,
  693.     "The value of the prefix argument for the next editing command.\n\
  694. It may be a number, or the symbol `-' for just a minus sign as arg,\n\
  695. or a list whose car is a number for just one or more C-U's\n\
  696. or nil if no argument has been specified.\n\
  697. \n\
  698. You cannot examine this variable to find the argument for this command\n\
  699. since it has been set to nil by the time you can look.\n\
  700. Instead, you should use the variable `current-prefix-arg', although\n\
  701. normally commands can get this prefix argument with (interactive \"P\").");
  702.   Vprefix_arg = Qnil;
  703.  
  704.   DEFVAR_LISP ("current-prefix-arg", &Vcurrent_prefix_arg,
  705.     "The value of the prefix argument for this editing command.\n\
  706. It may be a number, or the symbol `-' for just a minus sign as arg,\n\
  707. or a list whose car is a number for just one or more C-U's\n\
  708. or nil if no argument has been specified.\n\
  709. This is what `(interactive \"P\")' returns.");
  710.   Vcurrent_prefix_arg = Qnil;
  711.  
  712.   DEFVAR_LISP ("current-mouse-event", &Vcurrent_mouse_event,
  713.     "The mouse-button event which invoked this command, or nil.\n\
  714. This is what `(interactive \"e\")' returns.");
  715.   Vcurrent_mouse_event = Qnil;
  716.  
  717.   DEFVAR_LISP ("command-history", &Vcommand_history,
  718.     "List of recent commands that read arguments from terminal.\n\
  719. Each command is represented as a form to evaluate.");
  720.   Vcommand_history = Qnil;
  721.  
  722.   DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status,
  723.     "Debugging status of current interactive command.\n\
  724. Bound each time `call-interactively' is called;\n\
  725. may be set by the debugger as a reminder for itself.");
  726.   Vcommand_debug_status = Qnil;
  727.  
  728.   defsubr (&Sinteractive);
  729.   defsubr (&Scall_interactively);
  730.   defsubr (&Sprefix_numeric_value);
  731. }
  732.