aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov2010-08-23 00:27:59 +0100
committerJuri Linkov2010-08-23 00:27:59 +0100
commit7133b7ee629457053e63db2a7f192037407da57b (patch)
tree3f3fe53c4a3233abfa0aec4e4c64516627236e74 /lisp
parent198a7a97ff99b96523f7c0736aa303d305595094 (diff)
downloademacs-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 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/simple.el34
2 files changed, 41 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9452ac294dd..c1fae3283ac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12010-08-22 Juri Linkov <juri@jurta.org>
2
3 * simple.el (read-extended-command): New function with the logic
4 for `completing-read' moved to Elisp from `execute-extended-command'.
5 Use `function-called-at-point' in `minibuffer-default-add-function'
6 to get a command name for M-n (bug#5364, bug#5214).
7
12010-08-22 Chong Yidong <cyd@stupidchicken.com> 82010-08-22 Chong Yidong <cyd@stupidchicken.com>
2 9
3 * startup.el (command-line-1): Issue warning for ignored arguments 10 * startup.el (command-line-1): Issue warning for ignored arguments
diff --git a/lisp/simple.el b/lisp/simple.el
index 5f62b9d9e73..c1ec78da7b9 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1301,6 +1301,40 @@ to get different commands to edit and resubmit."
1301 (if command-history 1301 (if command-history
1302 (error "Argument %d is beyond length of command history" arg) 1302 (error "Argument %d is beyond length of command history" arg)
1303 (error "There are no previous complex commands to repeat"))))) 1303 (error "There are no previous complex commands to repeat")))))
1304
1305(defun read-extended-command ()
1306 "Read command name to invoke in `execute-extended-command'."
1307 (minibuffer-with-setup-hook
1308 (lambda ()
1309 (set (make-local-variable 'minibuffer-default-add-function)
1310 (lambda ()
1311 ;; Get a command name at point in the original buffer
1312 ;; to propose it after M-n.
1313 (with-current-buffer (window-buffer (minibuffer-selected-window))
1314 (and (commandp (function-called-at-point))
1315 (format "%S" (function-called-at-point)))))))
1316 ;; Read a string, completing from and restricting to the set of
1317 ;; all defined commands. Don't provide any initial input.
1318 ;; Save the command read on the extended-command history list.
1319 (completing-read
1320 (concat (cond
1321 ((eq current-prefix-arg '-) "- ")
1322 ((and (consp current-prefix-arg)
1323 (eq (car current-prefix-arg) 4)) "C-u ")
1324 ((and (consp current-prefix-arg)
1325 (integerp (car current-prefix-arg)))
1326 (format "%d " (car current-prefix-arg)))
1327 ((integerp current-prefix-arg)
1328 (format "%d " current-prefix-arg)))
1329 ;; This isn't strictly correct if `execute-extended-command'
1330 ;; is bound to anything else (e.g. [menu]).
1331 ;; It could use (key-description (this-single-command-keys)),
1332 ;; but actually a prompt other than "M-x" would be confusing,
1333 ;; because "M-x" is a well-known prompt to read a command
1334 ;; and it serves as a shorthand for "Extended command: ".
1335 "M-x ")
1336 obarray 'commandp t nil 'extended-command-history)))
1337
1304 1338
1305(defvar minibuffer-history nil 1339(defvar minibuffer-history nil
1306 "Default minibuffer history list. 1340 "Default minibuffer history list.