emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111837: * lisp/simple.el (command-ex


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111837: * lisp/simple.el (command-execute): Move from C. Add obsolete check.
Date: Wed, 20 Feb 2013 11:37:06 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111837
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-02-20 11:37:06 -0500
message:
  * lisp/simple.el (command-execute): Move from C.  Add obsolete check.
  (extended-command-history): Move from C.
  * src/keyboard.c (Qcommand_execute): New var.
  (command_loop_1, read_char): Use it.
  (Fcommand_execute): Remove, replace by an Elisp implementation.
  (syms_of_keyboard): Adjust accordingly.
modified:
  lisp/ChangeLog
  lisp/simple.el
  src/ChangeLog
  src/keyboard.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-20 14:30:23 +0000
+++ b/lisp/ChangeLog    2013-02-20 16:37:06 +0000
@@ -1,3 +1,8 @@
+2013-02-20  Stefan Monnier  <address@hidden>
+
+       * simple.el (command-execute): Move from C.  Add obsolete check.
+       (extended-command-history): Move from C.
+
 2013-02-20  Ulrich Müller  <address@hidden>
 
        * jka-cmpr-hook.el (jka-compr-compression-info-list)

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2013-02-15 23:47:50 +0000
+++ b/lisp/simple.el    2013-02-20 16:37:06 +0000
@@ -1400,6 +1400,8 @@
          (error "Argument %d is beyond length of command history" arg)
        (error "There are no previous complex commands to repeat")))))
 
+(defvar extended-command-history nil)
+
 (defun read-extended-command ()
   "Read command name to invoke in `execute-extended-command'."
   (minibuffer-with-setup-hook
@@ -1489,6 +1491,53 @@
             (sit-for (if (numberp suggest-key-bindings)
                          suggest-key-bindings
                        2))))))))
+
+(defun command-execute (cmd &optional record-flag keys special)
+  ;; BEWARE: Called directly from the C code.
+  "Execute CMD as an editor command.
+CMD must be a symbol that satisfies the `commandp' predicate.
+Optional second arg RECORD-FLAG non-nil
+means unconditionally put this command in the variable `command-history'.
+Otherwise, that is done only if an arg is read using the minibuffer.
+The argument KEYS specifies the value to use instead of (this-command-keys)
+when reading the arguments; if it is nil, (this-command-keys) is used.
+The argument SPECIAL, if non-nil, means that this command is executing
+a special event, so ignore the prefix argument and don't clear it."
+  (setq debug-on-next-call nil)
+  (let ((prefixarg (unless special
+                     (prog1 prefix-arg
+                       (setq current-prefix-arg prefix-arg)
+                       (setq prefix-arg nil)))))
+    (and (symbolp cmd)
+         (get cmd 'disabled)
+         ;; FIXME: Weird calling convention!
+         (run-hooks 'disabled-command-function))
+    (let ((final cmd))
+      (while
+          (progn
+            (setq final (indirect-function final))
+            (if (autoloadp final)
+                (setq final (autoload-do-load final cmd)))))
+      (cond
+       ((arrayp final)
+        ;; If requested, place the macro in the command history.  For
+        ;; other sorts of commands, call-interactively takes care of this.
+        (when record-flag
+          (push `(execute-kbd-macro ,final ,prefixarg) command-history)
+          ;; Don't keep command history around forever.
+          (when (and (numberp history-length) (> history-length 0))
+            (let ((cell (nthcdr history-length command-history)))
+              (if (consp cell) (setcdr cell nil)))))
+        (execute-kbd-macro final prefixarg))
+       (t
+        ;; Pass `cmd' rather than `final', for the backtrace's sake.
+        (prog1 (call-interactively cmd record-flag keys)
+          (when (and (symbolp cmd)
+                     (get cmd 'byte-obsolete-info)
+                     (not (get cmd 'command-execute-obsolete-warned)))
+            (put cmd 'command-execute-obsolete-warned t)
+            (message "%s" (macroexp--obsolete-warning
+                           cmd (get cmd 'byte-obsolete-info) "command")))))))))
 
 (defvar minibuffer-history nil
   "Default minibuffer history list.

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-02-20 05:56:28 +0000
+++ b/src/ChangeLog     2013-02-20 16:37:06 +0000
@@ -1,12 +1,21 @@
+2013-02-20  Stefan Monnier  <address@hidden>
+
+       * keyboard.c (Qcommand_execute): New var.
+       (command_loop_1, read_char): Use it.
+       (Fcommand_execute): Remove, replace by an Elisp implementation.
+       (syms_of_keyboard): Adjust accordingly.
+
 2013-02-19  Daniel Colascione <address@hidden>
+
        * sheap.c (report_sheap_usage): Use message, not message1, so
        that we don't try to create a buffer while we're in the middle
        of dumping Emacs.  Explain why.
+
 2013-02-20  Dmitry Antipov  <address@hidden>
        * search.c (find_newline): Return byte position in bytepos.
        Adjust comment.
-       (find_next_newline_no_quit, find_before_next_newline): Add
-       bytepos argument.
+       (find_next_newline_no_quit, find_before_next_newline):
+       Add bytepos argument.
        * lisp.h (find_newline, find_next_newline_no_quit)
        (find_before_next_newline): Adjust prototypes.
        * bidi.c (bidi_find_paragraph_start):

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2013-02-17 16:49:27 +0000
+++ b/src/keyboard.c    2013-02-20 16:37:06 +0000
@@ -367,7 +367,7 @@
 
 static Lisp_Object recursive_edit_unwind (Lisp_Object buffer);
 static Lisp_Object command_loop (void);
-static Lisp_Object Qextended_command_history;
+static Lisp_Object Qcommand_execute;
 EMACS_TIME timer_check (void);
 
 static void echo_now (void);
@@ -1583,11 +1583,11 @@
                  = (EQ (undo, BVAR (current_buffer, undo_list))
                     ? Qnil : BVAR (current_buffer, undo_list));
              }
-            Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil);
+            call1 (Qcommand_execute, Vthis_command);
 
 #ifdef HAVE_WINDOW_SYSTEM
          /* Do not check display_hourglass_p here, because
-            Fcommand_execute could change it, but we should cancel
+            `command-execute' could change it, but we should cancel
             hourglass cursor anyway.
             But don't cancel the hourglass within a macro
             just because a command in the macro finishes.  */
@@ -2842,7 +2842,7 @@
     {
       struct buffer *prev_buffer = current_buffer;
       last_input_event = c;
-      Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt);
+      call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt);
 
       if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time)
        /* We stopped being idle for this event; undo that.  This
@@ -9876,95 +9876,6 @@
   return unbind_to (count, Fvector (i, keybuf));
 }
 
-DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 4, 0,
-       doc: /* Execute CMD as an editor command.
-CMD must be a symbol that satisfies the `commandp' predicate.
-Optional second arg RECORD-FLAG non-nil
-means unconditionally put this command in the variable `command-history'.
-Otherwise, that is done only if an arg is read using the minibuffer.
-The argument KEYS specifies the value to use instead of (this-command-keys)
-when reading the arguments; if it is nil, (this-command-keys) is used.
-The argument SPECIAL, if non-nil, means that this command is executing
-a special event, so ignore the prefix argument and don't clear it.  */)
-  (Lisp_Object cmd, Lisp_Object record_flag, Lisp_Object keys, Lisp_Object 
special)
-{
-  register Lisp_Object final;
-  register Lisp_Object tem;
-  Lisp_Object prefixarg;
-
-  debug_on_next_call = 0;
-
-  if (NILP (special))
-    {
-      prefixarg = KVAR (current_kboard, Vprefix_arg);
-      Vcurrent_prefix_arg = prefixarg;
-      kset_prefix_arg (current_kboard, Qnil);
-    }
-  else
-    prefixarg = Qnil;
-
-  if (SYMBOLP (cmd))
-    {
-      tem = Fget (cmd, Qdisabled);
-      if (!NILP (tem))
-       {
-         tem = Fsymbol_value (Qdisabled_command_function);
-         if (!NILP (tem))
-           return Frun_hooks (1, &Qdisabled_command_function);
-       }
-    }
-
-  while (1)
-    {
-      final = Findirect_function (cmd, Qnil);
-
-      if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
-       {
-         struct gcpro gcpro1, gcpro2;
-
-         GCPRO2 (cmd, prefixarg);
-         Fautoload_do_load (final, cmd, Qnil);
-         UNGCPRO;
-       }
-      else
-       break;
-    }
-
-  if (STRINGP (final) || VECTORP (final))
-    {
-      /* If requested, place the macro in the command history.  For
-        other sorts of commands, call-interactively takes care of
-        this.  */
-      if (!NILP (record_flag))
-       {
-         Vcommand_history
-           = Fcons (Fcons (Qexecute_kbd_macro,
-                           Fcons (final, Fcons (prefixarg, Qnil))),
-                    Vcommand_history);
-
-         /* Don't keep command history around forever.  */
-         if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0)
-           {
-             tem = Fnthcdr (Vhistory_length, Vcommand_history);
-             if (CONSP (tem))
-               XSETCDR (tem, Qnil);
-           }
-       }
-
-      return Fexecute_kbd_macro (final, prefixarg, Qnil);
-    }
-
-  if (CONSP (final) || SUBRP (final) || COMPILEDP (final))
-    /* Don't call Fcall_interactively directly because we want to make
-       sure the backtrace has an entry for `call-interactively'.
-       For the same reason, pass `cmd' rather than `final'.  */
-      return call3 (Qcall_interactively, cmd, record_flag, keys);
-
-  return Qnil;
-}
-
-
-
 /* Return true if input events are pending.  */
 
 bool
@@ -11195,8 +11106,7 @@
   raw_keybuf = Fmake_vector (make_number (30), Qnil);
   staticpro (&raw_keybuf);
 
-  DEFSYM (Qextended_command_history, "extended-command-history");
-  Fset (Qextended_command_history, Qnil);
+  DEFSYM (Qcommand_execute, "command-execute");
 
   accent_key_syms = Qnil;
   staticpro (&accent_key_syms);
@@ -11235,7 +11145,6 @@
   defsubr (&Srecursive_edit);
   defsubr (&Strack_mouse);
   defsubr (&Sinput_pending_p);
-  defsubr (&Scommand_execute);
   defsubr (&Srecent_keys);
   defsubr (&Sthis_command_keys);
   defsubr (&Sthis_command_keys_vector);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]