diff options
| author | Kim F. Storm | 2006-09-15 21:25:01 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-09-15 21:25:01 +0000 |
| commit | 05ca18a822791db528d4bc7be83399a6ef8d3497 (patch) | |
| tree | 1870f7156c9de2b1ef7d5d73c4b9383f203f2c4c | |
| parent | 0c9337fbd80574312e71c6e65acfb787a4312e26 (diff) | |
| download | emacs-05ca18a822791db528d4bc7be83399a6ef8d3497.tar.gz emacs-05ca18a822791db528d4bc7be83399a6ef8d3497.zip | |
(describe-key): Handle C-h k in *Help* buffer; collect
all necessary information about the event before erasing *Help*.
| -rw-r--r-- | lisp/help.el | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/lisp/help.el b/lisp/help.el index 72a45ec15bf..073bdd3c81c 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -665,19 +665,19 @@ temporarily enables it to allow getting help on disabled items and buttons." | |||
| 665 | (fset 'yank-menu (cons 'keymap yank-menu)))))) | 665 | (fset 'yank-menu (cons 'keymap yank-menu)))))) |
| 666 | (if (numberp untranslated) | 666 | (if (numberp untranslated) |
| 667 | (setq untranslated (this-single-command-raw-keys))) | 667 | (setq untranslated (this-single-command-raw-keys))) |
| 668 | (let* ((event (if (and (symbolp (aref key 0)) | 668 | (let* ((event (aref key (if (and (symbolp (aref key 0)) |
| 669 | (> (length key) 1) | 669 | (> (length key) 1) |
| 670 | (consp (aref key 1))) | 670 | (consp (aref key 1))) |
| 671 | (aref key 1) | 671 | 1 |
| 672 | (aref key 0))) | 672 | 0))) |
| 673 | (modifiers (event-modifiers event)) | 673 | (modifiers (event-modifiers event)) |
| 674 | (mousep | 674 | (mousep (or (memq 'click modifiers) (memq 'down modifiers) |
| 675 | (or (memq 'click modifiers) (memq 'down modifiers) | 675 | (memq 'drag modifiers))) |
| 676 | (memq 'drag modifiers)))) | 676 | (defn (key-binding key t)) |
| 677 | ;; Ok, now look up the key and name the command. | 677 | defn-up defn-up-tricky ev-type |
| 678 | mouse-1-remapped mouse-1-tricky) | ||
| 678 | 679 | ||
| 679 | (let ((defn (key-binding key t))) | 680 | ;; Handle the case where we faked an entry in "Select and Paste" menu. |
| 680 | ;; Handle the case where we faked an entry in "Select and Paste" menu. | ||
| 681 | (if (and (eq defn nil) | 681 | (if (and (eq defn nil) |
| 682 | (stringp (aref key (1- (length key)))) | 682 | (stringp (aref key (1- (length key)))) |
| 683 | (eq (key-binding (substring key 0 -1)) 'yank-menu)) | 683 | (eq (key-binding (substring key 0 -1)) 'yank-menu)) |
| @@ -692,6 +692,28 @@ temporarily enables it to allow getting help on disabled items and buttons." | |||
| 692 | (stringp (aref untranslated (1- (length untranslated))))) | 692 | (stringp (aref untranslated (1- (length untranslated))))) |
| 693 | (aset untranslated (1- (length untranslated)) | 693 | (aset untranslated (1- (length untranslated)) |
| 694 | "(any string)")) | 694 | "(any string)")) |
| 695 | ;; Need to do this before erasing *Help* buffer in case event | ||
| 696 | ;; is a mouse click in an existing *Help* buffer. | ||
| 697 | (when up-event | ||
| 698 | (setq ev-type (event-basic-type up-event)) | ||
| 699 | (let ((sequence (vector up-event))) | ||
| 700 | (when (and (eq ev-type 'mouse-1) | ||
| 701 | mouse-1-click-follows-link | ||
| 702 | (not (eq mouse-1-click-follows-link 'double)) | ||
| 703 | (setq mouse-1-remapped | ||
| 704 | (mouse-on-link-p (event-start up-event)))) | ||
| 705 | (setq mouse-1-tricky (and (integerp mouse-1-click-follows-link) | ||
| 706 | (> mouse-1-click-follows-link 0))) | ||
| 707 | (cond ((stringp mouse-1-remapped) | ||
| 708 | (setq sequence mouse-1-remapped)) | ||
| 709 | ((vectorp mouse-1-remapped) | ||
| 710 | (setcar up-event (elt mouse-1-remapped 0))) | ||
| 711 | (t (setcar up-event 'mouse-2)))) | ||
| 712 | (setq defn-up (key-binding sequence nil nil (event-start up-event))) | ||
| 713 | (when mouse-1-tricky | ||
| 714 | (setq sequence (vector up-event)) | ||
| 715 | (aset sequence 0 'mouse-1) | ||
| 716 | (setq defn-up-tricky (key-binding sequence nil nil (event-start up-event)))))) | ||
| 695 | (with-output-to-temp-buffer (help-buffer) | 717 | (with-output-to-temp-buffer (help-buffer) |
| 696 | (princ (help-key-description key untranslated)) | 718 | (princ (help-key-description key untranslated)) |
| 697 | (if mousep | 719 | (if mousep |
| @@ -701,30 +723,16 @@ temporarily enables it to allow getting help on disabled items and buttons." | |||
| 701 | (princ "\n which is ") | 723 | (princ "\n which is ") |
| 702 | (describe-function-1 defn) | 724 | (describe-function-1 defn) |
| 703 | (when up-event | 725 | (when up-event |
| 704 | (let ((type (event-basic-type up-event)) | 726 | (let ((hdr "\n\n-------------- up event ---------------\n\n")) |
| 705 | (hdr "\n\n-------------- up event ---------------\n\n") | 727 | (setq defn defn-up) |
| 706 | defn sequence | 728 | (unless (or (null defn) |
| 707 | mouse-1-tricky mouse-1-remapped) | 729 | (integerp defn) |
| 708 | (setq sequence (vector up-event)) | 730 | (equal defn 'undefined)) |
| 709 | (when (and (eq type 'mouse-1) | ||
| 710 | mouse-1-click-follows-link | ||
| 711 | (not (eq mouse-1-click-follows-link 'double)) | ||
| 712 | (setq mouse-1-remapped | ||
| 713 | (mouse-on-link-p (event-start up-event)))) | ||
| 714 | (setq mouse-1-tricky (and (integerp mouse-1-click-follows-link) | ||
| 715 | (> mouse-1-click-follows-link 0))) | ||
| 716 | (cond ((stringp mouse-1-remapped) | ||
| 717 | (setq sequence mouse-1-remapped)) | ||
| 718 | ((vectorp mouse-1-remapped) | ||
| 719 | (setcar up-event (elt mouse-1-remapped 0))) | ||
| 720 | (t (setcar up-event 'mouse-2)))) | ||
| 721 | (setq defn (key-binding sequence nil nil (event-start up-event))) | ||
| 722 | (unless (or (null defn) (integerp defn) (equal defn 'undefined)) | ||
| 723 | (princ (if mouse-1-tricky | 731 | (princ (if mouse-1-tricky |
| 724 | "\n\n----------------- up-event (short click) ----------------\n\n" | 732 | "\n\n----------------- up-event (short click) ----------------\n\n" |
| 725 | hdr)) | 733 | hdr)) |
| 726 | (setq hdr nil) | 734 | (setq hdr nil) |
| 727 | (princ (symbol-name type)) | 735 | (princ (symbol-name ev-type)) |
| 728 | (if mousep | 736 | (if mousep |
| 729 | (princ " at that spot")) | 737 | (princ " at that spot")) |
| 730 | (if mouse-1-remapped | 738 | (if mouse-1-remapped |
| @@ -734,10 +742,10 @@ temporarily enables it to allow getting help on disabled items and buttons." | |||
| 734 | (princ "\n which is ") | 742 | (princ "\n which is ") |
| 735 | (describe-function-1 defn)) | 743 | (describe-function-1 defn)) |
| 736 | (when mouse-1-tricky | 744 | (when mouse-1-tricky |
| 737 | (setcar up-event 'mouse-1) | 745 | (setq defn defn-up-tricky) |
| 738 | (setq defn (key-binding (vector up-event) nil nil | 746 | (unless (or (null defn) |
| 739 | (event-start up-event))) | 747 | (integerp defn) |
| 740 | (unless (or (null defn) (integerp defn) (eq defn 'undefined)) | 748 | (eq defn 'undefined)) |
| 741 | (princ (or hdr | 749 | (princ (or hdr |
| 742 | "\n\n----------------- up-event (long click) ----------------\n\n")) | 750 | "\n\n----------------- up-event (long click) ----------------\n\n")) |
| 743 | (princ "Pressing mouse-1") | 751 | (princ "Pressing mouse-1") |
| @@ -749,7 +757,7 @@ temporarily enables it to allow getting help on disabled items and buttons." | |||
| 749 | (prin1 defn) | 757 | (prin1 defn) |
| 750 | (princ "\n which is ") | 758 | (princ "\n which is ") |
| 751 | (describe-function-1 defn))))) | 759 | (describe-function-1 defn))))) |
| 752 | (print-help-return-message)))))) | 760 | (print-help-return-message))))) |
| 753 | 761 | ||
| 754 | (defun describe-mode (&optional buffer) | 762 | (defun describe-mode (&optional buffer) |
| 755 | "Display documentation of current major mode and minor modes. | 763 | "Display documentation of current major mode and minor modes. |