diff options
| author | Juri Linkov | 2010-08-23 00:27:59 +0100 |
|---|---|---|
| committer | Juri Linkov | 2010-08-23 00:27:59 +0100 |
| commit | 7133b7ee629457053e63db2a7f192037407da57b (patch) | |
| tree | 3f3fe53c4a3233abfa0aec4e4c64516627236e74 /src | |
| parent | 198a7a97ff99b96523f7c0736aa303d305595094 (diff) | |
| download | emacs-7133b7ee629457053e63db2a7f192037407da57b.tar.gz emacs-7133b7ee629457053e63db2a7f192037407da57b.zip | |
Move reading an extended command to Elisp (bug#5364, bug#5214).
* lisp/simple.el (read-extended-command): New function with the logic
for `completing-read' moved to Elisp from `execute-extended-command'.
Use `function-called-at-point' in `minibuffer-default-add-function'
to get a command name for M-n (bug#5364, bug#5214).
* src/keyboard.c (Fexecute_extended_command): Move reading a command name
with `completing-read' to a new Elisp function `read-extended-command'.
Call it to read a command to `function' (bug#5364, bug#5214).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 27 |
2 files changed, 8 insertions, 25 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a1e67df99e2..624cddb6fa7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2010-08-22 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * keyboard.c (Fexecute_extended_command): Move reading a command name | ||
| 4 | with `completing-read' to a new Elisp function `read-extended-command'. | ||
| 5 | Call it to read a command to `function' (bug#5364, bug#5214). | ||
| 6 | |||
| 1 | 2010-08-22 Chong Yidong <cyd@stupidchicken.com> | 7 | 2010-08-22 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 8 | ||
| 3 | * emacs.c (main): Remove handling of --unibyte arg (Bug#6886). | 9 | * emacs.c (main): Remove handling of --unibyte arg (Bug#6886). |
diff --git a/src/keyboard.c b/src/keyboard.c index 269e52988eb..b4a5d4e060f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10345,13 +10345,12 @@ give to the command you invoke, if it asks for an argument. */) | |||
| 10345 | (Lisp_Object prefixarg) | 10345 | (Lisp_Object prefixarg) |
| 10346 | { | 10346 | { |
| 10347 | Lisp_Object function; | 10347 | Lisp_Object function; |
| 10348 | char buf[40]; | ||
| 10349 | int saved_last_point_position; | 10348 | int saved_last_point_position; |
| 10350 | Lisp_Object saved_keys, saved_last_point_position_buffer; | 10349 | Lisp_Object saved_keys, saved_last_point_position_buffer; |
| 10351 | Lisp_Object bindings, value; | 10350 | Lisp_Object bindings, value; |
| 10352 | struct gcpro gcpro1, gcpro2, gcpro3; | 10351 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 10353 | #ifdef HAVE_WINDOW_SYSTEM | 10352 | #ifdef HAVE_WINDOW_SYSTEM |
| 10354 | /* The call to Fcompleting_read wil start and cancel the hourglass, | 10353 | /* The call to Fcompleting_read will start and cancel the hourglass, |
| 10355 | but if the hourglass was already scheduled, this means that no | 10354 | but if the hourglass was already scheduled, this means that no |
| 10356 | hourglass will be shown for the actual M-x command itself. | 10355 | hourglass will be shown for the actual M-x command itself. |
| 10357 | So we restart it if it is already scheduled. Note that checking | 10356 | So we restart it if it is already scheduled. Note that checking |
| @@ -10364,31 +10363,9 @@ give to the command you invoke, if it asks for an argument. */) | |||
| 10364 | XVECTOR (this_command_keys)->contents); | 10363 | XVECTOR (this_command_keys)->contents); |
| 10365 | saved_last_point_position_buffer = last_point_position_buffer; | 10364 | saved_last_point_position_buffer = last_point_position_buffer; |
| 10366 | saved_last_point_position = last_point_position; | 10365 | saved_last_point_position = last_point_position; |
| 10367 | buf[0] = 0; | ||
| 10368 | GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); | 10366 | GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); |
| 10369 | 10367 | ||
| 10370 | if (EQ (prefixarg, Qminus)) | 10368 | function = call0 (intern ("read-extended-command")); |
| 10371 | strcpy (buf, "- "); | ||
| 10372 | else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4) | ||
| 10373 | strcpy (buf, "C-u "); | ||
| 10374 | else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg))) | ||
| 10375 | sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg))); | ||
| 10376 | else if (INTEGERP (prefixarg)) | ||
| 10377 | sprintf (buf, "%ld ", (long) XINT (prefixarg)); | ||
| 10378 | |||
| 10379 | /* This isn't strictly correct if execute-extended-command | ||
| 10380 | is bound to anything else. Perhaps it should use | ||
| 10381 | this_command_keys? */ | ||
| 10382 | strcat (buf, "M-x "); | ||
| 10383 | |||
| 10384 | /* Prompt with buf, and then read a string, completing from and | ||
| 10385 | restricting to the set of all defined commands. Don't provide | ||
| 10386 | any initial input. Save the command read on the extended-command | ||
| 10387 | history list. */ | ||
| 10388 | function = Fcompleting_read (build_string (buf), | ||
| 10389 | Vobarray, Qcommandp, | ||
| 10390 | Qt, Qnil, Qextended_command_history, Qnil, | ||
| 10391 | Qnil); | ||
| 10392 | 10369 | ||
| 10393 | #ifdef HAVE_WINDOW_SYSTEM | 10370 | #ifdef HAVE_WINDOW_SYSTEM |
| 10394 | if (hstarted) start_hourglass (); | 10371 | if (hstarted) start_hourglass (); |