aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-02-20 11:37:06 -0500
committerStefan Monnier2013-02-20 11:37:06 -0500
commitb6c2bfff02239197fc855c0575def855afab01c7 (patch)
treed5e7870aeaa28b3bbeb3bdb77b0bcac886b939cc
parent5079cfefc0fe7152bae4ea175f5679bca42e0cbd (diff)
downloademacs-b6c2bfff02239197fc855c0575def855afab01c7.tar.gz
emacs-b6c2bfff02239197fc855c0575def855afab01c7.zip
* 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.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el49
-rw-r--r--src/ChangeLog13
-rw-r--r--src/keyboard.c101
4 files changed, 70 insertions, 98 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0a1e93ac19c..abcf6578060 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12013-02-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * simple.el (command-execute): Move from C. Add obsolete check.
4 (extended-command-history): Move from C.
5
12013-02-20 Ulrich Müller <ulm@gentoo.org> 62013-02-20 Ulrich Müller <ulm@gentoo.org>
2 7
3 * jka-cmpr-hook.el (jka-compr-compression-info-list) 8 * jka-cmpr-hook.el (jka-compr-compression-info-list)
diff --git a/lisp/simple.el b/lisp/simple.el
index 138c2420309..3ef700a6058 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1400,6 +1400,8 @@ to get different commands to edit and resubmit."
1400 (error "Argument %d is beyond length of command history" arg) 1400 (error "Argument %d is beyond length of command history" arg)
1401 (error "There are no previous complex commands to repeat"))))) 1401 (error "There are no previous complex commands to repeat")))))
1402 1402
1403(defvar extended-command-history nil)
1404
1403(defun read-extended-command () 1405(defun read-extended-command ()
1404 "Read command name to invoke in `execute-extended-command'." 1406 "Read command name to invoke in `execute-extended-command'."
1405 (minibuffer-with-setup-hook 1407 (minibuffer-with-setup-hook
@@ -1489,6 +1491,53 @@ give to the command you invoke, if it asks for an argument."
1489 (sit-for (if (numberp suggest-key-bindings) 1491 (sit-for (if (numberp suggest-key-bindings)
1490 suggest-key-bindings 1492 suggest-key-bindings
1491 2)))))))) 1493 2))))))))
1494
1495(defun command-execute (cmd &optional record-flag keys special)
1496 ;; BEWARE: Called directly from the C code.
1497 "Execute CMD as an editor command.
1498CMD must be a symbol that satisfies the `commandp' predicate.
1499Optional second arg RECORD-FLAG non-nil
1500means unconditionally put this command in the variable `command-history'.
1501Otherwise, that is done only if an arg is read using the minibuffer.
1502The argument KEYS specifies the value to use instead of (this-command-keys)
1503when reading the arguments; if it is nil, (this-command-keys) is used.
1504The argument SPECIAL, if non-nil, means that this command is executing
1505a special event, so ignore the prefix argument and don't clear it."
1506 (setq debug-on-next-call nil)
1507 (let ((prefixarg (unless special
1508 (prog1 prefix-arg
1509 (setq current-prefix-arg prefix-arg)
1510 (setq prefix-arg nil)))))
1511 (and (symbolp cmd)
1512 (get cmd 'disabled)
1513 ;; FIXME: Weird calling convention!
1514 (run-hooks 'disabled-command-function))
1515 (let ((final cmd))
1516 (while
1517 (progn
1518 (setq final (indirect-function final))
1519 (if (autoloadp final)
1520 (setq final (autoload-do-load final cmd)))))
1521 (cond
1522 ((arrayp final)
1523 ;; If requested, place the macro in the command history. For
1524 ;; other sorts of commands, call-interactively takes care of this.
1525 (when record-flag
1526 (push `(execute-kbd-macro ,final ,prefixarg) command-history)
1527 ;; Don't keep command history around forever.
1528 (when (and (numberp history-length) (> history-length 0))
1529 (let ((cell (nthcdr history-length command-history)))
1530 (if (consp cell) (setcdr cell nil)))))
1531 (execute-kbd-macro final prefixarg))
1532 (t
1533 ;; Pass `cmd' rather than `final', for the backtrace's sake.
1534 (prog1 (call-interactively cmd record-flag keys)
1535 (when (and (symbolp cmd)
1536 (get cmd 'byte-obsolete-info)
1537 (not (get cmd 'command-execute-obsolete-warned)))
1538 (put cmd 'command-execute-obsolete-warned t)
1539 (message "%s" (macroexp--obsolete-warning
1540 cmd (get cmd 'byte-obsolete-info) "command")))))))))
1492 1541
1493(defvar minibuffer-history nil 1542(defvar minibuffer-history nil
1494 "Default minibuffer history list. 1543 "Default minibuffer history list.
diff --git a/src/ChangeLog b/src/ChangeLog
index b04b344edf2..9423484c656 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,12 +1,21 @@
12013-02-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * keyboard.c (Qcommand_execute): New var.
4 (command_loop_1, read_char): Use it.
5 (Fcommand_execute): Remove, replace by an Elisp implementation.
6 (syms_of_keyboard): Adjust accordingly.
7
12013-02-19 Daniel Colascione <dancol@dancol.org> 82013-02-19 Daniel Colascione <dancol@dancol.org>
9
2 * sheap.c (report_sheap_usage): Use message, not message1, so 10 * sheap.c (report_sheap_usage): Use message, not message1, so
3 that we don't try to create a buffer while we're in the middle 11 that we don't try to create a buffer while we're in the middle
4 of dumping Emacs. Explain why. 12 of dumping Emacs. Explain why.
13
52013-02-20 Dmitry Antipov <dmantipov@yandex.ru> 142013-02-20 Dmitry Antipov <dmantipov@yandex.ru>
6 * search.c (find_newline): Return byte position in bytepos. 15 * search.c (find_newline): Return byte position in bytepos.
7 Adjust comment. 16 Adjust comment.
8 (find_next_newline_no_quit, find_before_next_newline): Add 17 (find_next_newline_no_quit, find_before_next_newline):
9 bytepos argument. 18 Add bytepos argument.
10 * lisp.h (find_newline, find_next_newline_no_quit) 19 * lisp.h (find_newline, find_next_newline_no_quit)
11 (find_before_next_newline): Adjust prototypes. 20 (find_before_next_newline): Adjust prototypes.
12 * bidi.c (bidi_find_paragraph_start): 21 * bidi.c (bidi_find_paragraph_start):
diff --git a/src/keyboard.c b/src/keyboard.c
index 77037f647e9..9cb9dd0b47b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -367,7 +367,7 @@ Lisp_Object Qmenu_bar;
367 367
368static Lisp_Object recursive_edit_unwind (Lisp_Object buffer); 368static Lisp_Object recursive_edit_unwind (Lisp_Object buffer);
369static Lisp_Object command_loop (void); 369static Lisp_Object command_loop (void);
370static Lisp_Object Qextended_command_history; 370static Lisp_Object Qcommand_execute;
371EMACS_TIME timer_check (void); 371EMACS_TIME timer_check (void);
372 372
373static void echo_now (void); 373static void echo_now (void);
@@ -1583,11 +1583,11 @@ command_loop_1 (void)
1583 = (EQ (undo, BVAR (current_buffer, undo_list)) 1583 = (EQ (undo, BVAR (current_buffer, undo_list))
1584 ? Qnil : BVAR (current_buffer, undo_list)); 1584 ? Qnil : BVAR (current_buffer, undo_list));
1585 } 1585 }
1586 Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); 1586 call1 (Qcommand_execute, Vthis_command);
1587 1587
1588#ifdef HAVE_WINDOW_SYSTEM 1588#ifdef HAVE_WINDOW_SYSTEM
1589 /* Do not check display_hourglass_p here, because 1589 /* Do not check display_hourglass_p here, because
1590 Fcommand_execute could change it, but we should cancel 1590 `command-execute' could change it, but we should cancel
1591 hourglass cursor anyway. 1591 hourglass cursor anyway.
1592 But don't cancel the hourglass within a macro 1592 But don't cancel the hourglass within a macro
1593 just because a command in the macro finishes. */ 1593 just because a command in the macro finishes. */
@@ -2842,7 +2842,7 @@ read_char (int commandflag, Lisp_Object map,
2842 { 2842 {
2843 struct buffer *prev_buffer = current_buffer; 2843 struct buffer *prev_buffer = current_buffer;
2844 last_input_event = c; 2844 last_input_event = c;
2845 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt); 2845 call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt);
2846 2846
2847 if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) 2847 if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time)
2848 /* We stopped being idle for this event; undo that. This 2848 /* We stopped being idle for this event; undo that. This
@@ -9876,95 +9876,6 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
9876 return unbind_to (count, Fvector (i, keybuf)); 9876 return unbind_to (count, Fvector (i, keybuf));
9877} 9877}
9878 9878
9879DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 4, 0,
9880 doc: /* Execute CMD as an editor command.
9881CMD must be a symbol that satisfies the `commandp' predicate.
9882Optional second arg RECORD-FLAG non-nil
9883means unconditionally put this command in the variable `command-history'.
9884Otherwise, that is done only if an arg is read using the minibuffer.
9885The argument KEYS specifies the value to use instead of (this-command-keys)
9886when reading the arguments; if it is nil, (this-command-keys) is used.
9887The argument SPECIAL, if non-nil, means that this command is executing
9888a special event, so ignore the prefix argument and don't clear it. */)
9889 (Lisp_Object cmd, Lisp_Object record_flag, Lisp_Object keys, Lisp_Object special)
9890{
9891 register Lisp_Object final;
9892 register Lisp_Object tem;
9893 Lisp_Object prefixarg;
9894
9895 debug_on_next_call = 0;
9896
9897 if (NILP (special))
9898 {
9899 prefixarg = KVAR (current_kboard, Vprefix_arg);
9900 Vcurrent_prefix_arg = prefixarg;
9901 kset_prefix_arg (current_kboard, Qnil);
9902 }
9903 else
9904 prefixarg = Qnil;
9905
9906 if (SYMBOLP (cmd))
9907 {
9908 tem = Fget (cmd, Qdisabled);
9909 if (!NILP (tem))
9910 {
9911 tem = Fsymbol_value (Qdisabled_command_function);
9912 if (!NILP (tem))
9913 return Frun_hooks (1, &Qdisabled_command_function);
9914 }
9915 }
9916
9917 while (1)
9918 {
9919 final = Findirect_function (cmd, Qnil);
9920
9921 if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
9922 {
9923 struct gcpro gcpro1, gcpro2;
9924
9925 GCPRO2 (cmd, prefixarg);
9926 Fautoload_do_load (final, cmd, Qnil);
9927 UNGCPRO;
9928 }
9929 else
9930 break;
9931 }
9932
9933 if (STRINGP (final) || VECTORP (final))
9934 {
9935 /* If requested, place the macro in the command history. For
9936 other sorts of commands, call-interactively takes care of
9937 this. */
9938 if (!NILP (record_flag))
9939 {
9940 Vcommand_history
9941 = Fcons (Fcons (Qexecute_kbd_macro,
9942 Fcons (final, Fcons (prefixarg, Qnil))),
9943 Vcommand_history);
9944
9945 /* Don't keep command history around forever. */
9946 if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0)
9947 {
9948 tem = Fnthcdr (Vhistory_length, Vcommand_history);
9949 if (CONSP (tem))
9950 XSETCDR (tem, Qnil);
9951 }
9952 }
9953
9954 return Fexecute_kbd_macro (final, prefixarg, Qnil);
9955 }
9956
9957 if (CONSP (final) || SUBRP (final) || COMPILEDP (final))
9958 /* Don't call Fcall_interactively directly because we want to make
9959 sure the backtrace has an entry for `call-interactively'.
9960 For the same reason, pass `cmd' rather than `final'. */
9961 return call3 (Qcall_interactively, cmd, record_flag, keys);
9962
9963 return Qnil;
9964}
9965
9966
9967
9968/* Return true if input events are pending. */ 9879/* Return true if input events are pending. */
9969 9880
9970bool 9881bool
@@ -11195,8 +11106,7 @@ syms_of_keyboard (void)
11195 raw_keybuf = Fmake_vector (make_number (30), Qnil); 11106 raw_keybuf = Fmake_vector (make_number (30), Qnil);
11196 staticpro (&raw_keybuf); 11107 staticpro (&raw_keybuf);
11197 11108
11198 DEFSYM (Qextended_command_history, "extended-command-history"); 11109 DEFSYM (Qcommand_execute, "command-execute");
11199 Fset (Qextended_command_history, Qnil);
11200 11110
11201 accent_key_syms = Qnil; 11111 accent_key_syms = Qnil;
11202 staticpro (&accent_key_syms); 11112 staticpro (&accent_key_syms);
@@ -11235,7 +11145,6 @@ syms_of_keyboard (void)
11235 defsubr (&Srecursive_edit); 11145 defsubr (&Srecursive_edit);
11236 defsubr (&Strack_mouse); 11146 defsubr (&Strack_mouse);
11237 defsubr (&Sinput_pending_p); 11147 defsubr (&Sinput_pending_p);
11238 defsubr (&Scommand_execute);
11239 defsubr (&Srecent_keys); 11148 defsubr (&Srecent_keys);
11240 defsubr (&Sthis_command_keys); 11149 defsubr (&Sthis_command_keys);
11241 defsubr (&Sthis_command_keys_vector); 11150 defsubr (&Sthis_command_keys_vector);