diff options
| -rw-r--r-- | lisp/help.el | 73 |
1 files changed, 54 insertions, 19 deletions
diff --git a/lisp/help.el b/lisp/help.el index d81e433f755..e416fd3d887 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -167,12 +167,29 @@ Commands: | |||
| 167 | (and (symbolp type) | 167 | (and (symbolp type) |
| 168 | (memq 'down (event-modifiers type)) | 168 | (memq 'down (event-modifiers type)) |
| 169 | (read-event))) | 169 | (read-event))) |
| 170 | (let ((defn (key-binding key))) | 170 | (save-excursion |
| 171 | (if (or (null defn) (integerp defn)) | 171 | (let ((modifiers (event-modifiers (aref key 0))) |
| 172 | (message "%s is undefined" (key-description key)) | 172 | window position) |
| 173 | (message "%s runs the command %s" | 173 | ;; For a mouse button event, go to the button it applies to |
| 174 | (key-description key) | 174 | ;; to get the right key bindings. And go to the right place |
| 175 | (if (symbolp defn) defn (prin1-to-string defn)))))) | 175 | ;; in case the keymap depends on where you clicked. |
| 176 | (if (or (memq 'click modifiers) (memq 'down modifiers) | ||
| 177 | (memq 'drag modifiers)) | ||
| 178 | (setq window (posn-window (event-start (aref key 0))) | ||
| 179 | position (posn-point (event-start (aref key 0))))) | ||
| 180 | (if (windowp window) | ||
| 181 | (progn | ||
| 182 | (set-buffer (window-buffer window)) | ||
| 183 | (goto-char position))) | ||
| 184 | ;; Ok, now look up the key and name the command. | ||
| 185 | (let ((defn (key-binding key))) | ||
| 186 | (if (or (null defn) (integerp defn)) | ||
| 187 | (message "%s is undefined" (key-description key)) | ||
| 188 | (message (if (windowp window) | ||
| 189 | "%s at that spot runs the command %s" | ||
| 190 | "%s runs the command %s") | ||
| 191 | (key-description key) | ||
| 192 | (if (symbolp defn) defn (prin1-to-string defn)))))))) | ||
| 176 | 193 | ||
| 177 | (defun print-help-return-message (&optional function) | 194 | (defun print-help-return-message (&optional function) |
| 178 | "Display or return message saying how to restore windows after help command. | 195 | "Display or return message saying how to restore windows after help command. |
| @@ -255,19 +272,37 @@ If FUNCTION is nil, applies `message' to it, thus printing it." | |||
| 255 | (and (symbolp type) | 272 | (and (symbolp type) |
| 256 | (memq 'down (event-modifiers type)) | 273 | (memq 'down (event-modifiers type)) |
| 257 | (read-event))) | 274 | (read-event))) |
| 258 | (let ((defn (key-binding key))) | 275 | (save-excursion |
| 259 | (if (or (null defn) (integerp defn)) | 276 | (let ((modifiers (event-modifiers (aref key 0))) |
| 260 | (message "%s is undefined" (key-description key)) | 277 | window position) |
| 261 | (with-output-to-temp-buffer "*Help*" | 278 | ;; For a mouse button event, go to the button it applies to |
| 262 | (prin1 defn) | 279 | ;; to get the right key bindings. And go to the right place |
| 263 | (princ ":\n") | 280 | ;; in case the keymap depends on where you clicked. |
| 264 | (if (documentation defn) | 281 | (if (or (memq 'click modifiers) (memq 'down modifiers) |
| 265 | (princ (documentation defn)) | 282 | (memq 'drag modifiers)) |
| 266 | (princ "not documented")) | 283 | (setq window (posn-window (event-start (aref key 0))) |
| 267 | (save-excursion | 284 | position (posn-point (event-start (aref key 0))))) |
| 268 | (set-buffer standard-output) | 285 | (if (windowp window) |
| 269 | (help-mode)) | 286 | (progn |
| 270 | (print-help-return-message))))) | 287 | (set-buffer (window-buffer window)) |
| 288 | (goto-char position))) | ||
| 289 | (let ((defn (key-binding key))) | ||
| 290 | (if (or (null defn) (integerp defn)) | ||
| 291 | (message "%s is undefined" (key-description key)) | ||
| 292 | (with-output-to-temp-buffer "*Help*" | ||
| 293 | (princ (key-description key)) | ||
| 294 | (if (windowp window) | ||
| 295 | (princ " at that spot")) | ||
| 296 | (princ " runs the command ") | ||
| 297 | (prin1 defn) | ||
| 298 | (princ ":\n") | ||
| 299 | (if (documentation defn) | ||
| 300 | (princ (documentation defn)) | ||
| 301 | (princ "not documented")) | ||
| 302 | (save-excursion | ||
| 303 | (set-buffer standard-output) | ||
| 304 | (help-mode)) | ||
| 305 | (print-help-return-message))))))) | ||
| 271 | 306 | ||
| 272 | (defun describe-mode () | 307 | (defun describe-mode () |
| 273 | "Display documentation of current major mode and minor modes. | 308 | "Display documentation of current major mode and minor modes. |