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 /lisp | |
| 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 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 18 | ||||
| -rw-r--r-- | lisp/simple.el | 50 |
2 files changed, 62 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cb7e1377c92..cfc40bc01a8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,10 +1,16 @@ | |||
| 1 | 2012-05-01 Aaron S. Hawley <aaron.s.hawley@gmail.com> | ||
| 2 | Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 3 | |||
| 4 | * simple.el (suggest-key-bindings, execute-extended-command): | ||
| 5 | Move from keyboard.c. | ||
| 6 | |||
| 1 | 2012-05-01 Chong Yidong <cyd@gnu.org> | 7 | 2012-05-01 Chong Yidong <cyd@gnu.org> |
| 2 | 8 | ||
| 3 | * follow.el: Eliminate advice. | 9 | * follow.el: Eliminate advice. |
| 4 | (set-process-filter, process-filter, sit-for): Advice deleted. | 10 | (set-process-filter, process-filter, sit-for): Advice deleted. |
| 5 | (follow-mode-off-hook): Obsolete hook removed. | 11 | (follow-mode-off-hook): Obsolete hook removed. |
| 6 | (follow-avoid-tail-recenter-p, follow-process-filter-alist): Vars | 12 | (follow-avoid-tail-recenter-p, follow-process-filter-alist): |
| 7 | deleted. | 13 | Vars deleted. |
| 8 | (follow-auto): Use a :set function. | 14 | (follow-auto): Use a :set function. |
| 9 | (follow-mode): Rewritten. Don't advise process filters. | 15 | (follow-mode): Rewritten. Don't advise process filters. |
| 10 | (follow-switch-to-current-buffer-all, follow-scroll-up) | 16 | (follow-switch-to-current-buffer-all, follow-scroll-up) |
| @@ -25,13 +31,13 @@ | |||
| 25 | (follow-stop-intercept-process-output, follow-generic-filter): | 31 | (follow-stop-intercept-process-output, follow-generic-filter): |
| 26 | Functions deleted. | 32 | Functions deleted. |
| 27 | (follow-scroll-bar-toolkit-scroll, follow-scroll-bar-drag) | 33 | (follow-scroll-bar-toolkit-scroll, follow-scroll-bar-drag) |
| 28 | (follow-scroll-bar-scroll-up, follow-scroll-bar-scroll-down): New | 34 | (follow-scroll-bar-scroll-up, follow-scroll-bar-scroll-down): |
| 29 | functions, replacing advice on scroll-bar-* commands. | 35 | New functions, replacing advice on scroll-bar-* commands. |
| 30 | (follow-mwheel-scroll): New function (Bug#4112). | 36 | (follow-mwheel-scroll): New function (Bug#4112). |
| 31 | 37 | ||
| 32 | * comint.el (comint-adjust-point): New function. | 38 | * comint.el (comint-adjust-point): New function. |
| 33 | (comint-postoutput-scroll-to-bottom): Use it. Call | 39 | (comint-postoutput-scroll-to-bottom): Use it. |
| 34 | follow-comint-scroll-to-bottom for Follow mode buffers. | 40 | Call follow-comint-scroll-to-bottom for Follow mode buffers. |
| 35 | 41 | ||
| 36 | 2012-05-01 Glenn Morris <rgm@gnu.org> | 42 | 2012-05-01 Glenn Morris <rgm@gnu.org> |
| 37 | 43 | ||
diff --git a/lisp/simple.el b/lisp/simple.el index 55f7d1261ee..3d8a3a38dbd 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1354,6 +1354,56 @@ to get different commands to edit and resubmit." | |||
| 1354 | "M-x ") | 1354 | "M-x ") |
| 1355 | obarray 'commandp t nil 'extended-command-history))) | 1355 | obarray 'commandp t nil 'extended-command-history))) |
| 1356 | 1356 | ||
| 1357 | (defcustom suggest-key-bindings t | ||
| 1358 | "Non-nil means show the equivalent key-binding when M-x command has one. | ||
| 1359 | The value can be a length of time to show the message for. | ||
| 1360 | If the value is non-nil and not a number, we wait 2 seconds." | ||
| 1361 | :group 'keyboard | ||
| 1362 | :type '(choice (const :tag "off" nil) | ||
| 1363 | (integer :tag "time" 2) | ||
| 1364 | (other :tag "on"))) | ||
| 1365 | |||
| 1366 | (defun execute-extended-command (prefixarg &optional command-name) | ||
| 1367 | ;; Based on Fexecute_extended_command in keyboard.c of Emacs. | ||
| 1368 | ;; Aaron S. Hawley <aaron.s.hawley(at)gmail.com> 2009-08-24 | ||
| 1369 | "Read function name, then read its arguments and call it. | ||
| 1370 | |||
| 1371 | To pass a numeric argument to the command you are invoking with, specify | ||
| 1372 | the numeric argument to this command. | ||
| 1373 | |||
| 1374 | Noninteractively, the argument PREFIXARG is the prefix argument to | ||
| 1375 | give to the command you invoke, if it asks for an argument." | ||
| 1376 | (interactive (list current-prefix-arg (read-extended-command))) | ||
| 1377 | ;; Emacs<24 calling-convention was with a single `prefixarg' argument. | ||
| 1378 | (if (null command-name) (setq command-name (read-extended-command))) | ||
| 1379 | (let* ((function (and (stringp command-name) (intern-soft command-name))) | ||
| 1380 | (binding (and suggest-key-bindings | ||
| 1381 | (not executing-kbd-macro) | ||
| 1382 | (where-is-internal function overriding-local-map t)))) | ||
| 1383 | (unless (commandp function) | ||
| 1384 | (error "`%s' is not a valid command name" command-name)) | ||
| 1385 | ;; Set this_command_keys to the concatenation of saved-keys and | ||
| 1386 | ;; function, followed by a RET. | ||
| 1387 | (setq this-command function) | ||
| 1388 | (let ((prefix-arg prefixarg)) | ||
| 1389 | (command-execute function 'record)) | ||
| 1390 | ;; If enabled, show which key runs this command. | ||
| 1391 | (when binding | ||
| 1392 | ;; But first wait, and skip the message if there is input. | ||
| 1393 | (let* ((waited | ||
| 1394 | ;; If this command displayed something in the echo area; | ||
| 1395 | ;; wait a few seconds, then display our suggestion message. | ||
| 1396 | (sit-for (cond | ||
| 1397 | ((zerop (length (current-message))) 0) | ||
| 1398 | ((numberp suggest-key-bindings) suggest-key-bindings) | ||
| 1399 | (t 2))))) | ||
| 1400 | (when (and waited (not (consp unread-command-events))) | ||
| 1401 | (with-temp-message | ||
| 1402 | (format "You can run the command `%s' with %s" | ||
| 1403 | function (key-description binding)) | ||
| 1404 | (sit-for (if (numberp suggest-key-bindings) | ||
| 1405 | suggest-key-bindings | ||
| 1406 | 2)))))))) | ||
| 1357 | 1407 | ||
| 1358 | (defvar minibuffer-history nil | 1408 | (defvar minibuffer-history nil |
| 1359 | "Default minibuffer history list. | 1409 | "Default minibuffer history list. |