diff options
| author | Aaron S. Hawley | 2012-05-01 12:10:02 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-05-01 12:10:02 -0400 |
| commit | b593d6a999b21dfee6939b24866a5ec6fbe7d11b (patch) | |
| tree | bc67bc80b8bdeda71099126762fea3de59d47535 /src | |
| parent | 87233a14e07a61981e3ce51350efb8b7ee5adcd2 (diff) | |
| download | emacs-b593d6a999b21dfee6939b24866a5ec6fbe7d11b.tar.gz emacs-b593d6a999b21dfee6939b24866a5ec6fbe7d11b.zip | |
Reimplement execute-extended-command in Elisp.
* src/keyboard.c (Fexecute_extended_command, Vsuggest_key_bindings):
Move to simple.el.
* lisp/simple.el (suggest-key-bindings, execute-extended-command):
Move from keyboard.c.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/keyboard.c | 147 |
2 files changed, 13 insertions, 155 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0e17d5dd345..f624517efb2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-05-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * keyboard.c (Fexecute_extended_command, Vsuggest_key_bindings): | ||
| 4 | Move to simple.el. | ||
| 5 | |||
| 1 | 2012-05-01 Glenn Morris <rgm@gnu.org> | 6 | 2012-05-01 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * syssignal.h: Remove reference to BROKEN_SIGINFO (last used in | 8 | * syssignal.h: Remove reference to BROKEN_SIGINFO (last used in |
| @@ -52,8 +57,8 @@ | |||
| 52 | 57 | ||
| 53 | 2012-04-27 Eli Zaretskii <eliz@gnu.org> | 58 | 2012-04-27 Eli Zaretskii <eliz@gnu.org> |
| 54 | 59 | ||
| 55 | * dispnew.c (swap_glyph_pointers, copy_row_except_pointers): Don't | 60 | * dispnew.c (swap_glyph_pointers, copy_row_except_pointers): |
| 56 | overrun array limits of glyph row's used[] array. (Bug#11288) | 61 | Don't overrun array limits of glyph row's used[] array. (Bug#11288) |
| 57 | 62 | ||
| 58 | 2012-04-26 Eli Zaretskii <eliz@gnu.org> | 63 | 2012-04-26 Eli Zaretskii <eliz@gnu.org> |
| 59 | 64 | ||
| @@ -169,8 +174,8 @@ | |||
| 169 | (XD_CHECK_DBUS_SERIAL): Rename from CHECK_DBUS_SERIAL_GET_SERIAL. | 174 | (XD_CHECK_DBUS_SERIAL): Rename from CHECK_DBUS_SERIAL_GET_SERIAL. |
| 170 | (xd_signature, xd_append_arg): Allow float for integer types. | 175 | (xd_signature, xd_append_arg): Allow float for integer types. |
| 171 | (xd_get_connection_references): New function. | 176 | (xd_get_connection_references): New function. |
| 172 | (xd_get_connection_address): Rename from xd_initialize. Return | 177 | (xd_get_connection_address): Rename from xd_initialize. |
| 173 | cached address. | 178 | Return cached address. |
| 174 | (xd_remove_watch): Do not unset $DBUS_SESSION_BUS_ADDRESS. | 179 | (xd_remove_watch): Do not unset $DBUS_SESSION_BUS_ADDRESS. |
| 175 | (xd_close_bus): Rename from Fdbus_close_bus. Not needed on Lisp | 180 | (xd_close_bus): Rename from Fdbus_close_bus. Not needed on Lisp |
| 176 | level. | 181 | level. |
| @@ -188,8 +193,8 @@ | |||
| 188 | (Vdbus_message_type_invalid, Vdbus_message_type_method_call) | 193 | (Vdbus_message_type_invalid, Vdbus_message_type_method_call) |
| 189 | (Vdbus_message_type_method_return, Vdbus_message_type_error) | 194 | (Vdbus_message_type_method_return, Vdbus_message_type_error) |
| 190 | (Vdbus_message_type_signal): New defvars. | 195 | (Vdbus_message_type_signal): New defvars. |
| 191 | (Vdbus_registered_buses, Vdbus_registered_objects_table): Adapt | 196 | (Vdbus_registered_buses, Vdbus_registered_objects_table): |
| 192 | docstring. | 197 | Adapt docstring. |
| 193 | 198 | ||
| 194 | 2012-04-22 Paul Eggert <eggert@cs.ucla.edu> | 199 | 2012-04-22 Paul Eggert <eggert@cs.ucla.edu> |
| 195 | 200 | ||
| @@ -219,8 +224,8 @@ | |||
| 219 | 224 | ||
| 220 | 2012-04-21 Eduard Wiebe <usenet@pusto.de> | 225 | 2012-04-21 Eduard Wiebe <usenet@pusto.de> |
| 221 | 226 | ||
| 222 | * sysdep.c (list_system_processes, system_process_attributes): Add | 227 | * sysdep.c (list_system_processes, system_process_attributes): |
| 223 | implementation for FreeBSD (Bug#5243). | 228 | Add implementation for FreeBSD (Bug#5243). |
| 224 | 229 | ||
| 225 | 2012-04-21 Andreas Schwab <schwab@linux-m68k.org> | 230 | 2012-04-21 Andreas Schwab <schwab@linux-m68k.org> |
| 226 | 231 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 48b31d8b564..a1ad1fed325 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10341,146 +10341,6 @@ a special event, so ignore the prefix argument and don't clear it. */) | |||
| 10341 | 10341 | ||
| 10342 | 10342 | ||
| 10343 | 10343 | ||
| 10344 | DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, | ||
| 10345 | 1, 1, "P", | ||
| 10346 | doc: /* Read function name, then read its arguments and call it. | ||
| 10347 | |||
| 10348 | To pass a numeric argument to the command you are invoking with, specify | ||
| 10349 | the numeric argument to this command. | ||
| 10350 | |||
| 10351 | Noninteractively, the argument PREFIXARG is the prefix argument to | ||
| 10352 | give to the command you invoke, if it asks for an argument. */) | ||
| 10353 | (Lisp_Object prefixarg) | ||
| 10354 | { | ||
| 10355 | Lisp_Object function; | ||
| 10356 | EMACS_INT saved_last_point_position; | ||
| 10357 | Lisp_Object saved_keys, saved_last_point_position_buffer; | ||
| 10358 | Lisp_Object bindings, value; | ||
| 10359 | struct gcpro gcpro1, gcpro2, gcpro3; | ||
| 10360 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 10361 | /* The call to Fcompleting_read will start and cancel the hourglass, | ||
| 10362 | but if the hourglass was already scheduled, this means that no | ||
| 10363 | hourglass will be shown for the actual M-x command itself. | ||
| 10364 | So we restart it if it is already scheduled. Note that checking | ||
| 10365 | hourglass_shown_p is not enough, normally the hourglass is not shown, | ||
| 10366 | just scheduled to be shown. */ | ||
| 10367 | int hstarted = hourglass_started (); | ||
| 10368 | #endif | ||
| 10369 | |||
| 10370 | saved_keys = Fvector (this_command_key_count, | ||
| 10371 | XVECTOR (this_command_keys)->contents); | ||
| 10372 | saved_last_point_position_buffer = last_point_position_buffer; | ||
| 10373 | saved_last_point_position = last_point_position; | ||
| 10374 | GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); | ||
| 10375 | |||
| 10376 | function = call0 (intern ("read-extended-command")); | ||
| 10377 | |||
| 10378 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 10379 | if (hstarted) start_hourglass (); | ||
| 10380 | #endif | ||
| 10381 | |||
| 10382 | if (STRINGP (function) && SCHARS (function) == 0) | ||
| 10383 | error ("No command name given"); | ||
| 10384 | |||
| 10385 | /* Set this_command_keys to the concatenation of saved_keys and | ||
| 10386 | function, followed by a RET. */ | ||
| 10387 | { | ||
| 10388 | Lisp_Object *keys; | ||
| 10389 | int i; | ||
| 10390 | |||
| 10391 | this_command_key_count = 0; | ||
| 10392 | this_command_key_count_reset = 0; | ||
| 10393 | this_single_command_key_start = 0; | ||
| 10394 | |||
| 10395 | keys = XVECTOR (saved_keys)->contents; | ||
| 10396 | for (i = 0; i < ASIZE (saved_keys); i++) | ||
| 10397 | add_command_key (keys[i]); | ||
| 10398 | |||
| 10399 | for (i = 0; i < SCHARS (function); i++) | ||
| 10400 | add_command_key (Faref (function, make_number (i))); | ||
| 10401 | |||
| 10402 | add_command_key (make_number ('\015')); | ||
| 10403 | } | ||
| 10404 | |||
| 10405 | last_point_position = saved_last_point_position; | ||
| 10406 | last_point_position_buffer = saved_last_point_position_buffer; | ||
| 10407 | |||
| 10408 | UNGCPRO; | ||
| 10409 | |||
| 10410 | function = Fintern (function, Qnil); | ||
| 10411 | KVAR (current_kboard, Vprefix_arg) = prefixarg; | ||
| 10412 | Vthis_command = function; | ||
| 10413 | real_this_command = function; | ||
| 10414 | |||
| 10415 | /* If enabled, show which key runs this command. */ | ||
| 10416 | if (!NILP (Vsuggest_key_bindings) | ||
| 10417 | && NILP (Vexecuting_kbd_macro) | ||
| 10418 | && SYMBOLP (function)) | ||
| 10419 | bindings = Fwhere_is_internal (function, Voverriding_local_map, | ||
| 10420 | Qt, Qnil, Qnil); | ||
| 10421 | else | ||
| 10422 | bindings = Qnil; | ||
| 10423 | |||
| 10424 | value = Qnil; | ||
| 10425 | GCPRO3 (bindings, value, function); | ||
| 10426 | value = Fcommand_execute (function, Qt, Qnil, Qnil); | ||
| 10427 | |||
| 10428 | /* If the command has a key binding, print it now. */ | ||
| 10429 | if (!NILP (bindings) | ||
| 10430 | && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), | ||
| 10431 | Qmouse_movement))) | ||
| 10432 | { | ||
| 10433 | /* But first wait, and skip the message if there is input. */ | ||
| 10434 | Lisp_Object waited; | ||
| 10435 | |||
| 10436 | /* If this command displayed something in the echo area; | ||
| 10437 | wait a few seconds, then display our suggestion message. */ | ||
| 10438 | if (NILP (echo_area_buffer[0])) | ||
| 10439 | waited = sit_for (make_number (0), 0, 2); | ||
| 10440 | else if (NUMBERP (Vsuggest_key_bindings)) | ||
| 10441 | waited = sit_for (Vsuggest_key_bindings, 0, 2); | ||
| 10442 | else | ||
| 10443 | waited = sit_for (make_number (2), 0, 2); | ||
| 10444 | |||
| 10445 | if (!NILP (waited) && ! CONSP (Vunread_command_events)) | ||
| 10446 | { | ||
| 10447 | Lisp_Object binding; | ||
| 10448 | char *newmessage; | ||
| 10449 | int message_p = push_message (); | ||
| 10450 | int count = SPECPDL_INDEX (); | ||
| 10451 | ptrdiff_t newmessage_len, newmessage_alloc; | ||
| 10452 | USE_SAFE_ALLOCA; | ||
| 10453 | |||
| 10454 | record_unwind_protect (pop_message_unwind, Qnil); | ||
| 10455 | binding = Fkey_description (bindings, Qnil); | ||
| 10456 | newmessage_alloc = | ||
| 10457 | (sizeof "You can run the command `' with " | ||
| 10458 | + SBYTES (SYMBOL_NAME (function)) + SBYTES (binding)); | ||
| 10459 | SAFE_ALLOCA (newmessage, char *, newmessage_alloc); | ||
| 10460 | newmessage_len = | ||
| 10461 | esprintf (newmessage, "You can run the command `%s' with %s", | ||
| 10462 | SDATA (SYMBOL_NAME (function)), | ||
| 10463 | SDATA (binding)); | ||
| 10464 | message2 (newmessage, | ||
| 10465 | newmessage_len, | ||
| 10466 | STRING_MULTIBYTE (binding)); | ||
| 10467 | if (NUMBERP (Vsuggest_key_bindings)) | ||
| 10468 | waited = sit_for (Vsuggest_key_bindings, 0, 2); | ||
| 10469 | else | ||
| 10470 | waited = sit_for (make_number (2), 0, 2); | ||
| 10471 | |||
| 10472 | if (!NILP (waited) && message_p) | ||
| 10473 | restore_message (); | ||
| 10474 | |||
| 10475 | SAFE_FREE (); | ||
| 10476 | unbind_to (count, Qnil); | ||
| 10477 | } | ||
| 10478 | } | ||
| 10479 | |||
| 10480 | RETURN_UNGCPRO (value); | ||
| 10481 | } | ||
| 10482 | |||
| 10483 | |||
| 10484 | /* Return nonzero if input events are pending. */ | 10344 | /* Return nonzero if input events are pending. */ |
| 10485 | 10345 | ||
| 10486 | int | 10346 | int |
| @@ -11791,7 +11651,6 @@ syms_of_keyboard (void) | |||
| 11791 | defsubr (&Sset_quit_char); | 11651 | defsubr (&Sset_quit_char); |
| 11792 | defsubr (&Sset_input_mode); | 11652 | defsubr (&Sset_input_mode); |
| 11793 | defsubr (&Scurrent_input_mode); | 11653 | defsubr (&Scurrent_input_mode); |
| 11794 | defsubr (&Sexecute_extended_command); | ||
| 11795 | defsubr (&Sposn_at_point); | 11654 | defsubr (&Sposn_at_point); |
| 11796 | defsubr (&Sposn_at_x_y); | 11655 | defsubr (&Sposn_at_x_y); |
| 11797 | 11656 | ||
| @@ -12195,12 +12054,6 @@ If this variable is non-nil, `delayed-warnings-hook' will be run | |||
| 12195 | immediately after running `post-command-hook'. */); | 12054 | immediately after running `post-command-hook'. */); |
| 12196 | Vdelayed_warnings_list = Qnil; | 12055 | Vdelayed_warnings_list = Qnil; |
| 12197 | 12056 | ||
| 12198 | DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings, | ||
| 12199 | doc: /* Non-nil means show the equivalent key-binding when M-x command has one. | ||
| 12200 | The value can be a length of time to show the message for. | ||
| 12201 | If the value is non-nil and not a number, we wait 2 seconds. */); | ||
| 12202 | Vsuggest_key_bindings = Qt; | ||
| 12203 | |||
| 12204 | DEFVAR_LISP ("timer-list", Vtimer_list, | 12057 | DEFVAR_LISP ("timer-list", Vtimer_list, |
| 12205 | doc: /* List of active absolute time timers in order of increasing time. */); | 12058 | doc: /* List of active absolute time timers in order of increasing time. */); |
| 12206 | Vtimer_list = Qnil; | 12059 | Vtimer_list = Qnil; |