Fix -Wimplicit warnings.
[bpt/emacs.git] / src / callint.c
index 5cedc44..cc522c3 100644 (file)
@@ -1,5 +1,5 @@
 /* Call a Lisp function interactively.
-   Copyright (C) 1985, 1986, 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1985, 86, 93, 94, 95, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -92,19 +92,23 @@ e -- Parametrized event (i.e., one that's a list) that invoked this command.\n\
      This skips events that are integers or symbols.\n\
 f -- Existing file name.\n\
 F -- Possibly nonexistent file name.\n\
+i -- Ignored, i.e. always nil.  Does not do I/O.\n\
 k -- Key sequence (downcase the last event if needed to get a definition).\n\
 K -- Key sequence to be redefined (do not downcase the last event).\n\
 m -- Value of mark as number.  Does not do I/O.\n\
+M -- Any string.  Inherits the current input method.\n\
 n -- Number read using minibuffer.\n\
 N -- Raw prefix arg, or if none, do like code `n'.\n\
 p -- Prefix arg converted to number.  Does not do I/O.\n\
 P -- Prefix arg in raw form.  Does not do I/O.\n\
 r -- Region: point and mark as 2 numeric args, smallest first.  Does no I/O.\n\
-s -- Any string.\n\
+s -- Any string.  Does not inherit the current input method.\n\
 S -- Any symbol.\n\
 v -- Variable name: symbol that is user-variable-p.\n\
 x -- Lisp expression read but not evaluated.\n\
 X -- Lisp expression read and evaluated.\n\
+z -- Coding system.\n\
+Z -- Coding system, nil if no prefix arg.\n\
 In addition, if the string begins with `*'\n\
  then an error is signaled if the buffer is read-only.\n\
  This happens before reading any arguments.\n\
@@ -284,17 +288,18 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
     {
       /* Make a copy of string so that if a GC relocates specs,
         `string' will still be valid.  */
-      string = (unsigned char *) alloca (XSTRING (specs)->size + 1);
-      bcopy (XSTRING (specs)->data, string, XSTRING (specs)->size + 1);
+      string = (unsigned char *) alloca (STRING_BYTES (XSTRING (specs)) + 1);
+      bcopy (XSTRING (specs)->data, string,
+            STRING_BYTES (XSTRING (specs)) + 1);
     }
   else if (string == 0)
     {
       Lisp_Object input;
-      i = num_input_chars;
+      i = num_input_events;
       input = specs;
       /* Compute the arg values using the user's expression.  */
       specs = Feval (specs);
-      if (i != num_input_chars || !NILP (record_flag))
+      if (i != num_input_events || !NILP (record_flag))
        {
          /* We should record this command on the command history.  */
          Lisp_Object values, car;
@@ -438,9 +443,9 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
         corresponding to the Lisp strings in visargs.  */
       for (j = 1; j < i; j++)
        argstrings[j]
-         = EQ (visargs[j], Qnil)
-           ? (unsigned char *) ""
-             : XSTRING (visargs[j])->data;
+         = (EQ (visargs[j], Qnil)
+            ? (unsigned char *) ""
+            : XSTRING (visargs[j])->data);
 
       /* Process the format-string in prompt1, putting the output
         into callint_message.  Make callint_message bigger if necessary.
@@ -450,7 +455,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
        {
          int nchars = doprnt (callint_message, callint_message_size,
                               prompt1, (char *)0,
-                              j - 1, argstrings + 1);
+                              j - 1, (char **) argstrings + 1);
          if (nchars < callint_message_size)
            break;
          callint_message_size *= 2;
@@ -462,7 +467,8 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
        {
        case 'a':               /* Symbol defined as a function */
          visargs[i] = Fcompleting_read (build_string (callint_message),
-                                        Vobarray, Qfboundp, Qt, Qnil, Qnil);
+                                        Vobarray, Qfboundp, Qt,
+                                        Qnil, Qnil, Qnil, Qnil);
          /* Passing args[i] directly stimulates compiler bug */
          teml = visargs[i];
          args[i] = Fintern (teml, Qnil);
@@ -482,10 +488,10 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
          break;
 
         case 'c':              /* Character */
-         /* Use message_nolog rather than message1_nolog here,
+         /* Use message_with_string rather than message1_nolog here,
             so that nothing bad happens if callint_message is changed
             within Fread_char (by a timer, for example).  */
-         message_nolog ("%s", callint_message);
+         message_with_string ("%s", build_string (callint_message), 0);
          args[i] = Fread_char ();
          message1_nolog ((char *) 0);
          /* Passing args[i] directly stimulates compiler bug */
@@ -495,14 +501,15 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
 
        case 'C':               /* Command: symbol with interactive function */
          visargs[i] = Fcompleting_read (build_string (callint_message),
-                                        Vobarray, Qcommandp, Qt, Qnil, Qnil);
+                                        Vobarray, Qcommandp,
+                                        Qt, Qnil, Qnil, Qnil, Qnil);
          /* Passing args[i] directly stimulates compiler bug */
          teml = visargs[i];
          args[i] = Fintern (teml, Qnil);
          break;
 
        case 'd':               /* Value of point.  Does not do I/O.  */
-         Fset_marker (point_marker, make_number (PT), Qnil);
+         set_marker_both (point_marker, Qnil, PT, PT_BYTE);
          args[i] = point_marker;
          /* visargs[i] = Qnil; */
          varies[i] = 1;
@@ -523,6 +530,10 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
                                     Qnil, Qnil, Qnil, Qnil);
          break;
 
+       case 'i':               /* Ignore an argument -- Does not do I/O */
+         varies[i] = -1;
+         break;
+
        case 'k':               /* Key sequence. */
          {
            int speccount1 = specpdl_ptr - specpdl;
@@ -571,6 +582,12 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
          varies[i] = 2;
          break;
 
+       case 'M':               /* String read via minibuffer with
+                                  inheriting the current input method.  */
+         args[i] = Fread_string (build_string (callint_message),
+                                 Qnil, Qnil, Qnil, Qt);
+         break;
+
        case 'N':               /* Prefix arg, else number from minibuffer */
          if (!NILP (prefix_arg))
            goto have_prefix_arg;
@@ -583,12 +600,13 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
                if (!  first)
                  {
                    message ("Please enter a number.");
-                   sit_for (1, 0, 0, 0);
+                   sit_for (1, 0, 0, 0, 0);
                  }
                first = 0;
 
                tem = Fread_from_minibuffer (build_string (callint_message),
-                                            Qnil, Qnil, Qnil, Qnil);
+                                            Qnil, Qnil, Qnil, Qnil, Qnil,
+                                            Qnil);
                if (! STRINGP (tem) || XSTRING (tem)->size == 0)
                  args[i] = Qnil;
                else
@@ -614,7 +632,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
 
        case 'r':               /* Region, point and mark as 2 args. */
          check_mark ();
-         Fset_marker (point_marker, make_number (PT), Qnil);
+         set_marker_both (point_marker, Qnil, PT, PT_BYTE);
          /* visargs[i+1] = Qnil; */
          foo = marker_position (current_buffer->mark);
          /* visargs[i] = Qnil; */
@@ -624,13 +642,15 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
          varies[i] = 4;
          break;
 
-       case 's':               /* String read via minibuffer.  */
-         args[i] = Fread_string (build_string (callint_message), Qnil, Qnil);
+       case 's':               /* String read via minibuffer without
+                                  inheriting the current input method.  */
+         args[i] = Fread_string (build_string (callint_message),
+                                 Qnil, Qnil, Qnil, Qnil);
          break;
 
        case 'S':               /* Any symbol.  */
          visargs[i] = Fread_string (build_string (callint_message),
-                                    Qnil, Qnil);
+                                    Qnil, Qnil, Qnil, Qnil);
          /* Passing args[i] directly stimulates compiler bug */
          teml = visargs[i];
          args[i] = Fintern (teml, Qnil);
@@ -638,7 +658,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
 
        case 'v':               /* Variable name: symbol that is
                                   user-variable-p. */
-         args[i] = Fread_variable (build_string (callint_message));
+         args[i] = Fread_variable (build_string (callint_message), Qnil);
          visargs[i] = last_minibuf_string;
          break;
 
@@ -652,6 +672,26 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
          visargs[i] = last_minibuf_string;
          break;
 
+       case 'Z':               /* Coding-system symbol, or ignore the
+                                  argument if no prefix */
+         if (NILP (prefix_arg))
+           {
+             args[i] = Qnil;
+             varies[i] = -1;
+           }
+         else 
+           {
+             args[i]
+               = Fread_non_nil_coding_system (build_string (callint_message));
+             visargs[i] = last_minibuf_string;
+           }
+         break;
+
+       case 'z':               /* Coding-system symbol or nil */
+         args[i] = Fread_coding_system (build_string (callint_message), Qnil);
+         visargs[i] = last_minibuf_string;
+         break;
+
          /* We have a case for `+' so we get an error
             if anyone tries to define one here.  */
        case '+':
@@ -732,6 +772,7 @@ Its numeric meaning is what you would get from `(interactive \"p\")'.")
   return val;
 }
 
+void
 syms_of_callint ()
 {
   point_marker = Fmake_marker ();