aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2008-11-17 10:07:37 +0000
committerMartin Rudalics2008-11-17 10:07:37 +0000
commit6c73d986eb4ca31f389fb6f007df8376fc0601f8 (patch)
tree17b038e3de339efd68f9cfda5ce7c86e3035e1a9
parenta0c859f0436a217b7d30f688e1dfb77d57e11555 (diff)
downloademacs-6c73d986eb4ca31f389fb6f007df8376fc0601f8.tar.gz
emacs-6c73d986eb4ca31f389fb6f007df8376fc0601f8.zip
(three-step-help): Remove * from defcustom.
(make-help-screen): Don't iconify selected frame. (Bug#1322) Use when instead of if and cond within condition-case.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/help-macro.el225
2 files changed, 118 insertions, 111 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1aabd100644..6678353629d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12008-11-17 Martin Rudalics <rudalics@gmx.at> 12008-11-17 Martin Rudalics <rudalics@gmx.at>
2 2
3 * help-macro.el (three-step-help): Remove * from defcustom.
4 (make-help-screen): Don't iconify selected frame. (Bug#1322)
5 Use when instead of if and cond within condition-case.
6
3 * window.el (quit-window): Bind window to selected window when 7 * window.el (quit-window): Bind window to selected window when
4 trying to delete it. 8 trying to delete it.
5 9
diff --git a/lisp/help-macro.el b/lisp/help-macro.el
index cbe725e3274..8f925d1bd42 100644
--- a/lisp/help-macro.el
+++ b/lisp/help-macro.el
@@ -71,11 +71,11 @@
71 71
72;;;###autoload 72;;;###autoload
73(defcustom three-step-help nil 73(defcustom three-step-help nil
74 "*Non-nil means give more info about Help command in three steps. 74 "Non-nil means give more info about Help command in three steps.
75The three steps are simple prompt, prompt with all options, 75The three steps are simple prompt, prompt with all options, and
76and window listing and describing the options. 76window listing and describing the options.
77A value of nil means skip the middle step, so that 77A value of nil means skip the middle step, so that \\[help-command] \\[help-command]
78\\[help-command] \\[help-command] gives the window that lists the options." 78gives the window that lists the options."
79 :type 'boolean 79 :type 'boolean
80 :group 'help) 80 :group 'help)
81 81
@@ -88,113 +88,116 @@ If HELP-TEXT contains the sequence `%THIS-KEY%', that is replaced
88with the key sequence that invoked FNAME. 88with the key sequence that invoked FNAME.
89When FNAME finally does get a command, it executes that command 89When FNAME finally does get a command, it executes that command
90and then returns." 90and then returns."
91 (let ((doc-fn (intern (concat (symbol-name fname) "-doc")))) 91 (let ((doc-fn (intern (concat (symbol-name fname) "-doc"))))
92 `(progn 92 `(progn
93 (defun ,doc-fn () ,help-text) 93 (defun ,doc-fn () ,help-text)
94 (defun ,fname () 94 (defun ,fname ()
95 "Help command." 95 "Help command."
96 (interactive) 96 (interactive)
97 (let ((line-prompt 97 (let ((line-prompt
98 (substitute-command-keys ,help-line))) 98 (substitute-command-keys ,help-line)))
99 (if three-step-help 99 (when three-step-help
100 (message "%s" line-prompt)) 100 (message "%s" line-prompt))
101 (let* ((help-screen (documentation (quote ,doc-fn))) 101 (let* ((help-screen (documentation (quote ,doc-fn)))
102 ;; We bind overriding-local-map for very small 102 ;; We bind overriding-local-map for very small
103 ;; sections, *excluding* where we switch buffers 103 ;; sections, *excluding* where we switch buffers
104 ;; and where we execute the chosen help command. 104 ;; and where we execute the chosen help command.
105 (local-map (make-sparse-keymap)) 105 (local-map (make-sparse-keymap))
106 (new-minor-mode-map-alist minor-mode-map-alist) 106 (new-minor-mode-map-alist minor-mode-map-alist)
107 (prev-frame (selected-frame)) 107 (prev-frame (selected-frame))
108 config new-frame key char) 108 config new-frame key char)
109 (if (string-match "%THIS-KEY%" help-screen) 109 (when (string-match "%THIS-KEY%" help-screen)
110 (setq help-screen 110 (setq help-screen
111 (replace-match (key-description (substring (this-command-keys) 0 -1)) 111 (replace-match (key-description
112 t t help-screen))) 112 (substring (this-command-keys) 0 -1))
113 (unwind-protect 113 t t help-screen)))
114 (let ((minor-mode-map-alist nil)) 114 (unwind-protect
115 (setcdr local-map ,helped-map) 115 (let ((minor-mode-map-alist nil))
116 (define-key local-map [t] 'undefined) 116 (setcdr local-map ,helped-map)
117 ;; Make the scroll bar keep working normally. 117 (define-key local-map [t] 'undefined)
118 (define-key local-map [vertical-scroll-bar] 118 ;; Make the scroll bar keep working normally.
119 (lookup-key global-map [vertical-scroll-bar])) 119 (define-key local-map [vertical-scroll-bar]
120 (if three-step-help 120 (lookup-key global-map [vertical-scroll-bar]))
121 (progn 121 (if three-step-help
122 (setq key (let ((overriding-local-map local-map)) 122 (progn
123 (read-key-sequence nil))) 123 (setq key (let ((overriding-local-map local-map))
124 ;; Make the HELP key translate to C-h. 124 (read-key-sequence nil)))
125 (if (lookup-key function-key-map key) 125 ;; Make the HELP key translate to C-h.
126 (setq key (lookup-key function-key-map key))) 126 (if (lookup-key function-key-map key)
127 (setq char (aref key 0))) 127 (setq key (lookup-key function-key-map key)))
128 (setq char ??)) 128 (setq char (aref key 0)))
129 (if (or (eq char ??) (eq char help-char) 129 (setq char ??))
130 (when (or (eq char ??) (eq char help-char)
130 (memq char help-event-list)) 131 (memq char help-event-list))
131 (progn 132 (setq config (current-window-configuration))
132 (setq config (current-window-configuration)) 133 (switch-to-buffer-other-window "*Help*")
133 (switch-to-buffer-other-window "*Help*") 134 (and (fboundp 'make-frame)
134 (and (fboundp 'make-frame) 135 (not (eq (window-frame (selected-window))
135 (not (eq (window-frame (selected-window)) 136 prev-frame))
136 prev-frame)) 137 (setq new-frame (window-frame (selected-window))
137 (setq new-frame (window-frame (selected-window)) 138 config nil))
138 config nil)) 139 (setq buffer-read-only nil)
139 (setq buffer-read-only nil) 140 (let ((inhibit-read-only t))
140 (let ((inhibit-read-only t)) 141 (erase-buffer)
141 (erase-buffer) 142 (insert help-screen))
142 (insert help-screen)) 143 (let ((minor-mode-map-alist new-minor-mode-map-alist))
143 (let ((minor-mode-map-alist new-minor-mode-map-alist)) 144 (help-mode)
144 (help-mode) 145 (setq new-minor-mode-map-alist minor-mode-map-alist))
145 (setq new-minor-mode-map-alist minor-mode-map-alist)) 146 (goto-char (point-min))
146 (goto-char (point-min)) 147 (while (or (memq char (append help-event-list
147 (while (or (memq char (append help-event-list 148 (cons help-char '(?? ?\C-v ?\s ?\177 delete backspace vertical-scroll-bar ?\M-v))))
148 (cons help-char '(?? ?\C-v ?\s ?\177 delete backspace vertical-scroll-bar ?\M-v)))) 149 (eq (car-safe char) 'switch-frame)
149 (eq (car-safe char) 'switch-frame) 150 (equal key "\M-v"))
150 (equal key "\M-v")) 151 (condition-case nil
151 (condition-case nil 152 (cond
152 (progn 153 ((eq (car-safe char) 'switch-frame)
153 (if (eq (car-safe char) 'switch-frame) 154 (handle-switch-frame char))
154 (handle-switch-frame char)) 155 ((memq char '(?\C-v ?\s))
155 (if (memq char '(?\C-v ?\s)) 156 (scroll-up))
156 (scroll-up)) 157 ((or (memq char '(?\177 ?\M-v delete backspace))
157 (if (or (memq char '(?\177 ?\M-v 158 (equal key "\M-v"))
158 delete backspace)) 159 (scroll-down)))
159 (equal key "\M-v")) 160 (error nil))
160 (scroll-down))) 161 (let ((cursor-in-echo-area t)
161 (error nil)) 162 (overriding-local-map local-map))
162 (let ((cursor-in-echo-area t) 163 (setq key (read-key-sequence
163 (overriding-local-map local-map)) 164 (format "Type one of the options listed%s: "
164 (setq key (read-key-sequence 165 (if (pos-visible-in-window-p
165 (format "Type one of the options listed%s: " 166 (point-max))
166 (if (pos-visible-in-window-p 167 "" ", or SPACE or DEL to scroll")))
167 (point-max)) 168 char (aref key 0)))
168 "" ", or SPACE or DEL to scroll"))) 169
169 char (aref key 0))) 170 ;; If this is a scroll bar command, just run it.
170 171 (when (eq char 'vertical-scroll-bar)
171 ;; If this is a scroll bar command, just run it. 172 (command-execute (lookup-key local-map key) nil key))))
172 (when (eq char 'vertical-scroll-bar) 173 ;; We don't need the prompt any more.
173 (command-execute (lookup-key local-map key) nil key))))) 174 (message "")
174 ;; We don't need the prompt any more. 175 ;; Mouse clicks are not part of the help feature,
175 (message "") 176 ;; so reexecute them in the standard environment.
176 ;; Mouse clicks are not part of the help feature, 177 (if (listp char)
177 ;; so reexecute them in the standard environment. 178 (setq unread-command-events
178 (if (listp char) 179 (cons char unread-command-events)
179 (setq unread-command-events 180 config nil)
180 (cons char unread-command-events) 181 (let ((defn (lookup-key local-map key)))
181 config nil) 182 (if defn
182 (let ((defn (lookup-key local-map key))) 183 (progn
183 (if defn 184 (when config
184 (progn 185 (set-window-configuration config)
185 (if config 186 (setq config nil))
186 (progn 187 ;; `defn' must make sure that its frame is
187 (set-window-configuration config) 188 ;; selected, so we won't iconify it below.
188 (setq config nil))) 189 (call-interactively defn)
189 (if new-frame 190 (when new-frame
190 (progn (iconify-frame new-frame) 191 ;; Do not iconify the selected frame.
191 (setq new-frame nil))) 192 (unless (eq new-frame (selected-frame))
192 (call-interactively defn)) 193 (iconify-frame new-frame))
193 (ding))))) 194 (setq new-frame nil)))
194 (if new-frame (iconify-frame new-frame)) 195 (ding)))))
195 (if config 196 (when config
196 (set-window-configuration config)) 197 (set-window-configuration config))
197 (setq minor-mode-map-alist new-minor-mode-map-alist)))))))) 198 (when new-frame
199 (iconify-frame new-frame))
200 (setq minor-mode-map-alist new-minor-mode-map-alist))))))))
198 201
199(provide 'help-macro) 202(provide 'help-macro)
200 203