diff options
| author | Richard M. Stallman | 1993-12-31 03:45:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-12-31 03:45:08 +0000 |
| commit | 657a790941c2074501634e2d278225af0d729d1d (patch) | |
| tree | 26683f35808b3b2c46449f617dce3f42d1699177 | |
| parent | ef586bbd32f786783ad6642a754a2f7b39c06bd0 (diff) | |
| download | emacs-657a790941c2074501634e2d278225af0d729d1d.tar.gz emacs-657a790941c2074501634e2d278225af0d729d1d.zip | |
(make-help-screen): Use read-key-sequence.
Temporarily switch keymaps.
| -rw-r--r-- | lisp/help-macro.el | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/lisp/help-macro.el b/lisp/help-macro.el index d12db10a270..61fde2c58b2 100644 --- a/lisp/help-macro.el +++ b/lisp/help-macro.el | |||
| @@ -72,52 +72,70 @@ | |||
| 72 | (require 'backquote) | 72 | (require 'backquote) |
| 73 | 73 | ||
| 74 | (defmacro make-help-screen (fname help-line help-text helped-map) | 74 | (defmacro make-help-screen (fname help-line help-text helped-map) |
| 75 | "Constructs function FNAME that when invoked shows HELP-LINE and if a help | 75 | "Construct help-menu function name FNAME. |
| 76 | character is requested, shows HELP-TEXT. The user is prompted for a character | 76 | When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP. |
| 77 | from the HELPED-MAP and the corresponding interactive function is executed." | 77 | If the command is the help character is requested, FNAME displays HELP-TEXT |
| 78 | and continues trying to read a command using HELPED-MAP. | ||
| 79 | When FNAME finally does get a command, it executes that command | ||
| 80 | and then returns." | ||
| 78 | (` (defun (, fname) () | 81 | (` (defun (, fname) () |
| 79 | (, help-text) | 82 | (, help-text) |
| 80 | (interactive) | 83 | (interactive) |
| 81 | (let ((line-prompt | 84 | (let ((line-prompt |
| 82 | (substitute-command-keys (, help-line)))) | 85 | (substitute-command-keys (, help-line))) |
| 86 | (help-screen (documentation (quote (, fname))))) | ||
| 83 | (message line-prompt) | 87 | (message line-prompt) |
| 84 | (let ((char (read-event)) | 88 | (let ((old-local-map (current-local-map)) |
| 85 | config) | 89 | (old-global-map (current-global-map)) |
| 90 | (minor-mode-map-alist nil) | ||
| 91 | config key char) | ||
| 86 | (unwind-protect | 92 | (unwind-protect |
| 87 | (progn | 93 | (progn |
| 94 | (use-global-map (, helped-map)) | ||
| 95 | (use-local-map nil) | ||
| 96 | (setq key (read-key-sequence nil)) | ||
| 97 | (setq char (aref key 0)) | ||
| 88 | (if (or (eq char ??) (eq char help-char)) | 98 | (if (or (eq char ??) (eq char help-char)) |
| 89 | (progn | 99 | (progn |
| 90 | (setq config (current-window-configuration)) | 100 | (setq config (current-window-configuration)) |
| 91 | (switch-to-buffer-other-window "*Help*") | 101 | (switch-to-buffer-other-window "*Help*") |
| 92 | (erase-buffer) | 102 | (erase-buffer) |
| 93 | (insert (documentation (quote (, fname)))) | 103 | (insert help-screen) |
| 94 | (goto-char (point-min)) | 104 | (goto-char (point-min)) |
| 95 | (while (memq char (cons help-char '(?? ?\C-v ?\ ?\177 ?\M-v))) | 105 | (while (memq char (cons help-char '(?? ?\C-v ?\ ?\177 ?\M-v))) |
| 96 | (if (memq char '(?\C-v ?\ )) | 106 | (condition-case nil |
| 97 | (scroll-up)) | 107 | (progn |
| 98 | (if (memq char '(?\177 ?\M-v)) | 108 | (if (memq char '(?\C-v ?\ )) |
| 99 | (scroll-down)) | 109 | (scroll-up)) |
| 110 | (if (memq char '(?\177 ?\M-v)) | ||
| 111 | (scroll-down))) | ||
| 112 | (error nil)) | ||
| 100 | (message "%s%s: " | 113 | (message "%s%s: " |
| 101 | line-prompt | 114 | line-prompt |
| 102 | (if (pos-visible-in-window-p (point-max)) | 115 | (if (pos-visible-in-window-p (point-max)) |
| 103 | "" " or Space to scroll")) | 116 | "" " or Space to scroll")) |
| 104 | (let ((cursor-in-echo-area t)) | 117 | (let ((cursor-in-echo-area t)) |
| 105 | (setq char (read-event)))))) | 118 | (setq key (read-key-sequence nil) |
| 106 | 119 | char (aref key 0)))))) | |
| 107 | (let ((defn (cdr (assq (if (integerp char) (downcase char) char) (, helped-map))))) | 120 | ;; Mouse clicks are not part of the help feature, |
| 108 | (if defn | 121 | ;; so reexecute them in the standard environment. |
| 109 | (if (keymapp defn) | 122 | (if (listp char) |
| 110 | (error "sorry, this command cannot be run from the help screen. Start over.") | 123 | (setq unread-command-events |
| 111 | (if config | 124 | (cons char unread-command-events) |
| 112 | (progn | 125 | config nil) |
| 113 | (set-window-configuration config) | 126 | (let ((defn (key-binding key))) |
| 114 | (setq config nil))) | 127 | (if defn |
| 115 | (call-interactively defn)) | 128 | (progn |
| 116 | (if (listp char) | 129 | (if config |
| 117 | (setq unread-command-events | 130 | (progn |
| 118 | (cons char unread-command-events) | 131 | (set-window-configuration config) |
| 119 | config nil) | 132 | (setq config nil))) |
| 133 | (use-local-map old-local-map) | ||
| 134 | (use-global-map old-global-map) | ||
| 135 | (call-interactively defn)) | ||
| 120 | (ding))))) | 136 | (ding))))) |
| 137 | (use-local-map old-local-map) | ||
| 138 | (use-global-map old-global-map) | ||
| 121 | (if config | 139 | (if config |
| 122 | (set-window-configuration config)))))) | 140 | (set-window-configuration config)))))) |
| 123 | )) | 141 | )) |