[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#5364: 23.1.91; execute-extended-command should do like FFAP
From: |
Juri Linkov |
Subject: |
bug#5364: 23.1.91; execute-extended-command should do like FFAP |
Date: |
Fri, 15 Jan 2010 11:19:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (x86_64-pc-linux-gnu) |
> The Elisp code looks OK, except it should be in the C file. Please move
> it to simple.el where we can edit it with edebug, font-lock, eldoc, ...
A patch for post-23.2:
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2010-01-13 08:35:10 +0000
+++ lisp/simple.el 2010-01-15 09:14:30 +0000
@@ -1210,6 +1210,29 @@ (defun repeat-complex-command (arg)
(if command-history
(error "Argument %d is beyond length of command history" arg)
(error "There are no previous complex commands to repeat")))))
+
+(defun read-extended-command ()
+ "Read command name to invoke in `execute-extended-command'."
+ (minibuffer-with-setup-hook
+ (lambda ()
+ (set (make-local-variable 'minibuffer-default-add-function)
+ (lambda ()
+ (with-current-buffer (window-buffer (minibuffer-selected-window))
+ (and (commandp (function-called-at-point))
+ (format "%S" (function-called-at-point)))))))
+ (completing-read
+ (concat (cond
+ ((eq current-prefix-arg '-) "- ")
+ ((and (consp current-prefix-arg)
+ (eq (car current-prefix-arg) 4)) "C-u ")
+ ((and (consp current-prefix-arg)
+ (integerp (car current-prefix-arg)))
+ (format "%d " (car current-prefix-arg)))
+ ((integerp current-prefix-arg)
+ (format "%d " current-prefix-arg)))
+ (key-description (this-single-command-keys))
+ " ")
+ obarray 'commandp t nil 'extended-command-history)))
(defvar minibuffer-history nil
"Default minibuffer history list.
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2010-01-13 08:35:10 +0000
+++ src/keyboard.c 2010-01-15 09:17:15 +0000
@@ -10512,19 +10512,17 @@ (at your option) any later version.
DEFUN ("execute-extended-command", Fexecute_extended_command,
Sexecute_extended_command,
- 1, 1, "P",
- doc: /* Read function name, then read its arguments and call it.
+ 2, 2, "(list current-prefix-arg (read-extended-command))",
+ doc: /* Read arguments, then read FUNCTION name and call it.
To pass a numeric argument to the command you are invoking with, specify
the numeric argument to this command.
Noninteractively, the argument PREFIXARG is the prefix argument to
give to the command you invoke, if it asks for an argument. */)
- (prefixarg)
- Lisp_Object prefixarg;
+ (prefixarg, function)
+ Lisp_Object prefixarg, function;
{
- Lisp_Object function;
- char buf[40];
int saved_last_point_position;
Lisp_Object saved_keys, saved_last_point_position_buffer;
Lisp_Object bindings, value;
@@ -10543,32 +10541,8 @@ (at your option) any later version.
XVECTOR (this_command_keys)->contents);
saved_last_point_position_buffer = last_point_position_buffer;
saved_last_point_position = last_point_position;
- buf[0] = 0;
GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer);
- if (EQ (prefixarg, Qminus))
- strcpy (buf, "- ");
- else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4)
- strcpy (buf, "C-u ");
- else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg)))
- sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
- else if (INTEGERP (prefixarg))
- sprintf (buf, "%ld ", (long) XINT (prefixarg));
-
- /* This isn't strictly correct if execute-extended-command
- is bound to anything else. Perhaps it should use
- this_command_keys? */
- strcat (buf, "M-x ");
-
- /* Prompt with buf, and then read a string, completing from and
- restricting to the set of all defined commands. Don't provide
- any initial input. Save the command read on the extended-command
- history list. */
- function = Fcompleting_read (build_string (buf),
- Vobarray, Qcommandp,
- Qt, Qnil, Qextended_command_history, Qnil,
- Qnil);
-
#ifdef HAVE_WINDOW_SYSTEM
if (hstarted) start_hourglass ();
#endif
--
Juri Linkov
http://www.jurta.org/emacs/
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, (continued)
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, jidanni, 2010/01/12
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Stefan Monnier, 2010/01/12
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, jidanni, 2010/01/13
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Stefan Monnier, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Juri Linkov, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Stefan Monnier, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Juri Linkov, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Stefan Monnier, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Chong Yidong, 2010/01/14
- bug#5364: 23.1.91; execute-extended-command should do like FFAP, Stefan Monnier, 2010/01/15
- bug#5364: 23.1.91; execute-extended-command should do like FFAP,
Juri Linkov <=
bug#5364: 23.1.91; execute-extended-command should do like FFAP, Jan D., 2010/01/13
bug#5364: 23.1.91; execute-extended-command should do like FFAP, jidanni, 2010/01/14