Commit b6c2bfff authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent 5079cfef
2013-02-20 Stefan Monnier <monnier@iro.umontreal.ca>
* simple.el (command-execute): Move from C. Add obsolete check.
(extended-command-history): Move from C.
2013-02-20 Ulrich Müller <ulm@gentoo.org>
 
* jka-cmpr-hook.el (jka-compr-compression-info-list)
......
......@@ -1400,6 +1400,8 @@ to get different commands to edit and resubmit."
(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 @@ give to the command you invoke, if it asks for an argument."
(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.
......
2013-02-20 Stefan Monnier <monnier@iro.umontreal.ca>
* 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 <dancol@dancol.org>
* 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 <dmantipov@yandex.ru>
* 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):
......
......@@ -367,7 +367,7 @@ Lisp_Object Qmenu_bar;
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 @@ command_loop_1 (void)
= (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 @@ read_char (int commandflag, Lisp_Object map,
{
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
......@@ -9875,95 +9875,6 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
UNGCPRO;
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. */
......@@ -11195,8 +11106,7 @@ syms_of_keyboard (void)
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 @@ syms_of_keyboard (void)
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment