diff options
| author | Richard M. Stallman | 2006-02-13 16:18:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-02-13 16:18:46 +0000 |
| commit | 2c8ed53856868a6d294de75a013c8dc6c6220872 (patch) | |
| tree | af912c6b1462c2dce87f662e5d6367a2f05dc350 | |
| parent | fd5b25da6a3ea29591d128455b4ddd325b34a174 (diff) | |
| download | emacs-2c8ed53856868a6d294de75a013c8dc6c6220872.tar.gz emacs-2c8ed53856868a6d294de75a013c8dc6c6220872.zip | |
(describe-key-briefly, describe-key):
Do all arg-reading inside `interactive' spec.
(describe-key-briefly-internal, describe-key-internal):
Functions merged back into their callers.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/help.el | 112 |
2 files changed, 65 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b65f1d554c5..eb7094bb374 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2006-02-13 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * help.el (describe-key-briefly, describe-key): Do all arg-reading | ||
| 4 | inside `interactive' spec. | ||
| 5 | (describe-key-briefly-internal, describe-key-internal): | ||
| 6 | Functions merged back into their callers. | ||
| 7 | |||
| 1 | 2006-02-13 Martin Rudalics <rudalics@gmx.at> (tiny change) | 8 | 2006-02-13 Martin Rudalics <rudalics@gmx.at> (tiny change) |
| 2 | 9 | ||
| 3 | * info.el (info-xref-visited): Inherit from info-xref too. | 10 | * info.el (info-xref-visited): Inherit from info-xref too. |
diff --git a/lisp/help.el b/lisp/help.el index bea404f5112..76aeac0ef62 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -565,31 +565,30 @@ the last key hit are used. | |||
| 565 | 565 | ||
| 566 | If KEY is a menu item or a tool-bar button that is disabled, this command | 566 | If KEY is a menu item or a tool-bar button that is disabled, this command |
| 567 | temporarily enables it to allow getting help on disabled items and buttons." | 567 | temporarily enables it to allow getting help on disabled items and buttons." |
| 568 | (interactive) | 568 | (interactive |
| 569 | (let ((enable-disabled-menus-and-buttons t) | 569 | (let ((enable-disabled-menus-and-buttons t) |
| 570 | (save-yank-menu)) | 570 | (cursor-in-echo-area t) |
| 571 | (if key | 571 | saved-yank-menu) |
| 572 | ;; Non-interactive invocation | 572 | (unwind-protect |
| 573 | (describe-key-briefly-internal key insert untranslated) | 573 | (let (key) |
| 574 | ;; If yank-menu is empty, populate it temporarily, so that | 574 | ;; If yank-menu is empty, populate it temporarily, so that |
| 575 | ;; "Select and Paste" menu can generate a complete event | 575 | ;; "Select and Paste" menu can generate a complete event. |
| 576 | (if (null (cdr yank-menu)) | 576 | (when (null (cdr yank-menu)) |
| 577 | (unwind-protect | 577 | (setq saved-yank-menu (copy-sequence yank-menu)) |
| 578 | (progn | 578 | (menu-bar-update-yank-menu "(any string)" nil)) |
| 579 | (setq save-yank-menu (copy-sequence yank-menu)) | 579 | (setq key (read-key-sequence "Describe key (or click or menu item): ")) |
| 580 | (menu-bar-update-yank-menu "(any string)" nil) | 580 | (list |
| 581 | (call-interactively 'describe-key-briefly-internal)) | 581 | key |
| 582 | (progn (setq yank-menu (copy-sequence save-yank-menu)) | 582 | (prefix-numeric-value current-prefix-arg) |
| 583 | (fset 'yank-menu (cons 'keymap yank-menu)))) | 583 | ;; If KEY is a down-event, read the corresponding up-event |
| 584 | (call-interactively 'describe-key-briefly-internal))))) | 584 | ;; and use it as the third argument. |
| 585 | 585 | (if (and (consp key) (symbolp (car key)) | |
| 586 | (defun describe-key-briefly-internal (key &optional insert untranslated) | 586 | (memq 'down (cdr (get (car key) 'event-symbol-elements)))) |
| 587 | "Print the name of the function KEY invokes. KEY is a string. | 587 | (read-event)))) |
| 588 | If INSERT (the prefix arg) is non-nil, insert the message in the buffer. | 588 | ;; Put yank-menu back as it was, if we changed it. |
| 589 | If non-nil UNTRANSLATED is a vector of the untranslated events. | 589 | (when saved-yank-menu |
| 590 | It can also be a number in which case the untranslated events from | 590 | (setq yank-menu (copy-sequence saved-yank-menu)) |
| 591 | the last key hit are used." | 591 | (fset 'yank-menu (cons 'keymap yank-menu)))))) |
| 592 | (interactive "kDescribe key briefly: \nP\np") | ||
| 593 | (if (numberp untranslated) | 592 | (if (numberp untranslated) |
| 594 | (setq untranslated (this-single-command-raw-keys))) | 593 | (setq untranslated (this-single-command-raw-keys))) |
| 595 | (save-excursion | 594 | (save-excursion |
| @@ -611,6 +610,11 @@ the last key hit are used." | |||
| 611 | (let ((defn (or (string-key-binding key) | 610 | (let ((defn (or (string-key-binding key) |
| 612 | (key-binding key t))) | 611 | (key-binding key t))) |
| 613 | key-desc) | 612 | key-desc) |
| 613 | ;; Handle the case where we faked an entry in "Select and Paste" menu. | ||
| 614 | (if (and (eq defn nil) | ||
| 615 | (stringp (aref key (1- (length key)))) | ||
| 616 | (eq (key-binding (substring key 0 -1)) 'yank-menu)) | ||
| 617 | (setq defn 'menu-bar-select-yank)) | ||
| 614 | ;; Don't bother user with strings from (e.g.) the select-paste menu. | 618 | ;; Don't bother user with strings from (e.g.) the select-paste menu. |
| 615 | (if (stringp (aref key (1- (length key)))) | 619 | (if (stringp (aref key (1- (length key)))) |
| 616 | (aset key (1- (length key)) "(any string)")) | 620 | (aset key (1- (length key)) "(any string)")) |
| @@ -641,35 +645,30 @@ UP-EVENT is the up-event that was discarded by reading KEY, or nil. | |||
| 641 | 645 | ||
| 642 | If KEY is a menu item or a tool-bar button that is disabled, this command | 646 | If KEY is a menu item or a tool-bar button that is disabled, this command |
| 643 | temporarily enables it to allow getting help on disabled items and buttons." | 647 | temporarily enables it to allow getting help on disabled items and buttons." |
| 644 | (interactive) | 648 | (interactive |
| 645 | (let ((enable-disabled-menus-and-buttons t) | 649 | (let ((enable-disabled-menus-and-buttons t) |
| 646 | (save-yank-menu)) | 650 | (cursor-in-echo-area t) |
| 647 | (if key | 651 | saved-yank-menu) |
| 648 | ;; Non-interactive invocation | 652 | (unwind-protect |
| 649 | (describe-key-internal key untranslated up-event) | 653 | (let (key) |
| 650 | ;; If yank-menu is empty, populate it temporarily, so that | 654 | ;; If yank-menu is empty, populate it temporarily, so that |
| 651 | ;; "Select and Paste" menu can generate a complete event | 655 | ;; "Select and Paste" menu can generate a complete event. |
| 652 | (if (null (cdr yank-menu)) | 656 | (when (null (cdr yank-menu)) |
| 653 | (unwind-protect | 657 | (setq saved-yank-menu (copy-sequence yank-menu)) |
| 654 | (progn | 658 | (menu-bar-update-yank-menu "(any string)" nil)) |
| 655 | (setq save-yank-menu (copy-sequence yank-menu)) | 659 | (setq key (read-key-sequence "Describe key (or click or menu item): ")) |
| 656 | (menu-bar-update-yank-menu "(any string)" nil) | 660 | (list |
| 657 | (call-interactively 'describe-key-internal)) | 661 | key |
| 658 | (progn (setq yank-menu (copy-sequence save-yank-menu)) | 662 | (prefix-numeric-value current-prefix-arg) |
| 659 | (fset 'yank-menu (cons 'keymap yank-menu)))) | 663 | ;; If KEY is a down-event, read the corresponding up-event |
| 660 | (call-interactively 'describe-key-internal))))) | 664 | ;; and use it as the third argument. |
| 661 | 665 | (if (and (consp key) (symbolp (car key)) | |
| 662 | (defun describe-key-internal (key &optional untranslated up-event) | 666 | (memq 'down (cdr (get (car key) 'event-symbol-elements)))) |
| 663 | "Display documentation of the function invoked by KEY. | 667 | (read-event)))) |
| 664 | KEY can be any kind of a key sequence; it can include keyboard events, | 668 | ;; Put yank-menu back as it was, if we changed it. |
| 665 | mouse events, and/or menu events. When calling from a program, | 669 | (when saved-yank-menu |
| 666 | pass KEY as a string or a vector. | 670 | (setq yank-menu (copy-sequence saved-yank-menu)) |
| 667 | 671 | (fset 'yank-menu (cons 'keymap yank-menu)))))) | |
| 668 | If non-nil, UNTRANSLATED is a vector of the corresponding untranslated events. | ||
| 669 | It can also be a number, in which case the untranslated events from | ||
| 670 | the last key sequence entered are used. | ||
| 671 | UP-EVENT is the up-event that was discarded by reading KEY, or nil." | ||
| 672 | (interactive "kDescribe key (or click or menu item): \np\nU") | ||
| 673 | (if (numberp untranslated) | 672 | (if (numberp untranslated) |
| 674 | (setq untranslated (this-single-command-raw-keys))) | 673 | (setq untranslated (this-single-command-raw-keys))) |
| 675 | (save-excursion | 674 | (save-excursion |
| @@ -686,6 +685,11 @@ UP-EVENT is the up-event that was discarded by reading KEY, or nil." | |||
| 686 | (set-buffer (window-buffer window)) | 685 | (set-buffer (window-buffer window)) |
| 687 | (goto-char position)) | 686 | (goto-char position)) |
| 688 | (let ((defn (or (string-key-binding key) (key-binding key t)))) | 687 | (let ((defn (or (string-key-binding key) (key-binding key t)))) |
| 688 | ;; Handle the case where we faked an entry in "Select and Paste" menu. | ||
| 689 | (if (and (eq defn nil) | ||
| 690 | (stringp (aref key (1- (length key)))) | ||
| 691 | (eq (key-binding (substring key 0 -1)) 'yank-menu)) | ||
| 692 | (setq defn 'menu-bar-select-yank)) | ||
| 689 | (if (or (null defn) (integerp defn) (equal defn 'undefined)) | 693 | (if (or (null defn) (integerp defn) (equal defn 'undefined)) |
| 690 | (message "%s is undefined" (help-key-description key untranslated)) | 694 | (message "%s is undefined" (help-key-description key untranslated)) |
| 691 | (help-setup-xref (list #'describe-function defn) (interactive-p)) | 695 | (help-setup-xref (list #'describe-function defn) (interactive-p)) |