]> code.delx.au - gnu-emacs/blobdiff - src/callint.c
*** empty log message ***
[gnu-emacs] / src / callint.c
index f80f3c620274ae4c29331fc0b817c74cbcb98872..8b8cb0320959eac94dc27202a5c17de5e850fa94 100644 (file)
@@ -1,5 +1,5 @@
 /* Call a Lisp function interactively.
-   Copyright (C) 1985, 86, 93, 94, 95, 1997, 2000, 2002
+   Copyright (C) 1985, 86, 93, 94, 95, 1997, 2000, 02, 03, 2004
    Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -41,6 +41,7 @@ Lisp_Object Qcall_interactively;
 Lisp_Object Vcommand_history;
 
 extern Lisp_Object Vhistory_length;
+extern Lisp_Object Vthis_original_command, real_this_command;
 
 Lisp_Object Vcommand_debug_status, Qcommand_debug_status;
 Lisp_Object Qenable_recursive_minibuffers;
@@ -208,7 +209,7 @@ fix_command (input, values)
          Lisp_Object intail, valtail;
          for (intail = Fcdr (input), valtail = values;
               CONSP (valtail);
-              intail = Fcdr (intail), valtail = Fcdr (valtail))
+              intail = Fcdr (intail), valtail = XCDR (valtail))
            {
              Lisp_Object elt;
              elt = Fcar (intail);
@@ -255,7 +256,8 @@ Optional second arg RECORD-FLAG non-nil
 means unconditionally put this command in the command-history.
 Otherwise, this is done only if an arg is read using the minibuffer.
 Optional third arg KEYS, if given, specifies the sequence of events to
-supply if the command inquires which events were used to invoke it.  */)
+supply if the command inquires which events were used to invoke it.
+If KEYS is omitted or nil, the return value of `this-command-keys' is used.  */)
      (function, record_flag, keys)
      Lisp_Object function, record_flag, keys;
 {
@@ -291,6 +293,14 @@ supply if the command inquires which events were used to invoke it.  */)
   int key_count;
   int record_then_fail = 0;
 
+  Lisp_Object save_this_command, save_last_command;
+  Lisp_Object save_this_original_command, save_real_this_command;
+
+  save_this_command = Vthis_command;
+  save_this_original_command = Vthis_original_command;
+  save_real_this_command = real_this_command;
+  save_last_command = current_kboard->Vlast_command;
+
   if (NILP (keys))
     keys = this_command_keys, key_count = this_command_key_count;
   else
@@ -338,25 +348,17 @@ supply if the command inquires which events were used to invoke it.  */)
        goto lose;
       specs = XVECTOR (fun)->contents[COMPILED_INTERACTIVE];
     }
-  else if (!CONSP (fun))
-    goto lose;
-  else if (funcar = XCAR (fun), EQ (funcar, Qautoload))
+  else
     {
+      Lisp_Object form;
       GCPRO2 (function, prefix_arg);
-      do_autoload (fun, function);
+      form = Finteractive_form (function);
       UNGCPRO;
-      goto retry;
-    }
-  else if (EQ (funcar, Qlambda))
-    {
-      specs = Fassq (Qinteractive, Fcdr (XCDR (fun)));
-      if (NILP (specs))
+      if (CONSP (form))
+       specs = filter_specs = Fcar (XCDR (form));
+      else
        goto lose;
-      filter_specs = Fnth (make_number (1), specs);
-      specs = Fcar (Fcdr (specs));
     }
-  else
-    goto lose;
 
   /* If either SPECS or STRING is set to a string, use it.  */
   if (STRINGP (specs))
@@ -379,7 +381,7 @@ supply if the command inquires which events were used to invoke it.  */)
       if (i != num_input_events || !NILP (record_flag))
        {
          /* We should record this command on the command history.  */
-         Lisp_Object values, car;
+         Lisp_Object values;
          /* Make a copy of the list of values, for the command history,
             and turn them into things we can eval.  */
          values = quotify_args (Fcopy_sequence (specs));
@@ -395,6 +397,12 @@ supply if the command inquires which events were used to invoke it.  */)
                XSETCDR (teml, Qnil);
            }
        }
+
+      Vthis_command = save_this_command;
+      Vthis_original_command = save_this_original_command;
+      real_this_command= save_real_this_command;
+      current_kboard->Vlast_command = save_last_command;
+
       single_kboard_state ();
       return apply1 (function, specs);
     }
@@ -456,7 +464,7 @@ supply if the command inquires which events were used to invoke it.  */)
              if (!NILP (Vmouse_leave_buffer_hook))
                call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
 
-             Fselect_window (event);
+             Fselect_window (event, Qnil);
            }
          string++;
        }
@@ -605,7 +613,7 @@ supply if the command inquires which events were used to invoke it.  */)
                                          Qnil, Qnil, Qnil, Qnil);
            unbind_to (speccount1, Qnil);
            teml = args[i];
-           visargs[i] = Fkey_description (teml);
+           visargs[i] = Fkey_description (teml, Qnil);
 
            /* If the key sequence ends with a down-event,
               discard the following up-event.  */
@@ -632,7 +640,7 @@ supply if the command inquires which events were used to invoke it.  */)
            args[i] = Fread_key_sequence (build_string (callint_message),
                                          Qnil, Qt, Qnil, Qnil);
            teml = args[i];
-           visargs[i] = Fkey_description (teml);
+           visargs[i] = Fkey_description (teml, Qnil);
            unbind_to (speccount1, Qnil);
 
            /* If the key sequence ends with a down-event,
@@ -841,6 +849,11 @@ supply if the command inquires which events were used to invoke it.  */)
   if (record_then_fail)
     Fbarf_if_buffer_read_only ();
 
+  Vthis_command = save_this_command;
+  Vthis_original_command = save_this_original_command;
+  real_this_command= save_real_this_command;
+  current_kboard->Vlast_command = save_last_command;
+
   single_kboard_state ();
 
   {
@@ -978,3 +991,6 @@ a way to turn themselves off when a mouse command switches windows.  */);
   defsubr (&Scall_interactively);
   defsubr (&Sprefix_numeric_value);
 }
+
+/* arch-tag: a3a7cad7-bcac-42ce-916e-1bd2546ebf37
+   (do not change this comment) */