Mercurial > emacs
comparison lisp/help-macro.el @ 23331:8e860ff326de
(make-help-screen): Keep HELP-TEXT
in a separate function definition, not in the help command FNAME.
Replace %THIS-KEY% with the key sequence that ran FNAME.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 27 Sep 1998 21:17:00 +0000 |
parents | 116fb3c03737 |
children | 866b59632531 |
comparison
equal
deleted
inserted
replaced
23330:3f2ab6f2bb5c | 23331:8e860ff326de |
---|---|
82 (defmacro make-help-screen (fname help-line help-text helped-map) | 82 (defmacro make-help-screen (fname help-line help-text helped-map) |
83 "Construct help-menu function name FNAME. | 83 "Construct help-menu function name FNAME. |
84 When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP. | 84 When invoked, FNAME shows HELP-LINE and reads a command using HELPED-MAP. |
85 If the command is the help character, FNAME displays HELP-TEXT | 85 If the command is the help character, FNAME displays HELP-TEXT |
86 and continues trying to read a command using HELPED-MAP. | 86 and continues trying to read a command using HELPED-MAP. |
87 If HELP-TEXT contains the sequence `%THIS-KEY%', that is replaced | |
88 with the key sequence that invoked FNAME. | |
87 When FNAME finally does get a command, it executes that command | 89 When FNAME finally does get a command, it executes that command |
88 and then returns." | 90 and then returns." |
89 (` (defun (, fname) () | 91 (let ((doc-fn (intern (concat (symbol-name fname) "-doc")))) |
90 (, help-text) | 92 `(progn |
93 (defun ,doc-fn () ,help-text) | |
94 (defun ,fname () | |
95 "Help command." | |
91 (interactive) | 96 (interactive) |
92 (let ((line-prompt | 97 (let ((line-prompt |
93 (substitute-command-keys (, help-line)))) | 98 (substitute-command-keys ,help-line))) |
94 (if three-step-help | 99 (if three-step-help |
95 (message "%s" line-prompt)) | 100 (message "%s" line-prompt)) |
96 (let* ((help-screen (documentation (quote (, fname)))) | 101 (let* ((help-screen (documentation (quote ,doc-fn))) |
97 ;; We bind overriding-local-map for very small | 102 ;; We bind overriding-local-map for very small |
98 ;; sections, *excluding* where we switch buffers | 103 ;; sections, *excluding* where we switch buffers |
99 ;; and where we execute the chosen help command. | 104 ;; and where we execute the chosen help command. |
100 (local-map (make-sparse-keymap)) | 105 (local-map (make-sparse-keymap)) |
101 (minor-mode-map-alist nil) | 106 (minor-mode-map-alist nil) |
102 (prev-frame (selected-frame)) | 107 (prev-frame (selected-frame)) |
103 config new-frame key char) | 108 config new-frame key char) |
109 (if (string-match "%THIS-KEY%" help-screen) | |
110 (setq help-screen | |
111 (replace-match (key-description (substring (this-command-keys) 0 -1)) | |
112 t t help-screen))) | |
104 (unwind-protect | 113 (unwind-protect |
105 (progn | 114 (progn |
106 (setcdr local-map (, helped-map)) | 115 (setcdr local-map ,helped-map) |
107 (define-key local-map [t] 'undefined) | 116 (define-key local-map [t] 'undefined) |
108 ;; Make the scroll bar keep working normally. | 117 ;; Make the scroll bar keep working normally. |
109 (define-key local-map [vertical-scroll-bar] | 118 (define-key local-map [vertical-scroll-bar] |
110 (lookup-key global-map [vertical-scroll-bar])) | 119 (lookup-key global-map [vertical-scroll-bar])) |
111 (if three-step-help | 120 (if three-step-help |
180 (call-interactively defn)) | 189 (call-interactively defn)) |
181 (ding))))) | 190 (ding))))) |
182 (if new-frame (iconify-frame new-frame)) | 191 (if new-frame (iconify-frame new-frame)) |
183 (if config | 192 (if config |
184 (set-window-configuration config)))))) | 193 (set-window-configuration config)))))) |
185 )) | 194 ))) |
186 | 195 |
187 ;;; help-macro.el | 196 ;;; help-macro.el |
188 | 197 |