diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/help-fns.el | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index c97647c2d41..a5d38340438 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -43,6 +43,11 @@ The functions will receive the function name as argument.") | |||
| 43 | 43 | ||
| 44 | ;; Functions | 44 | ;; Functions |
| 45 | 45 | ||
| 46 | (defvar describe-function-orig-buffer nil | ||
| 47 | "Buffer that was current when 'describe-function' was invoked. | ||
| 48 | Functions on 'help-fns-describe-function-functions' can use this | ||
| 49 | to get buffer-local values.") | ||
| 50 | |||
| 46 | ;;;###autoload | 51 | ;;;###autoload |
| 47 | (defun describe-function (function) | 52 | (defun describe-function (function) |
| 48 | "Display the full documentation of FUNCTION (a symbol)." | 53 | "Display the full documentation of FUNCTION (a symbol)." |
| @@ -61,18 +66,35 @@ The functions will receive the function name as argument.") | |||
| 61 | (user-error "You didn't specify a function symbol")) | 66 | (user-error "You didn't specify a function symbol")) |
| 62 | (or (fboundp function) | 67 | (or (fboundp function) |
| 63 | (user-error "Symbol's function definition is void: %s" function)) | 68 | (user-error "Symbol's function definition is void: %s" function)) |
| 64 | (help-setup-xref (list #'describe-function function) | 69 | |
| 65 | (called-interactively-p 'interactive)) | 70 | ;; We save describe-function-orig-buffer on the help xref stack, so |
| 66 | (save-excursion | 71 | ;; it is restored by the back/forward buttons. 'help-buffer' |
| 67 | (with-help-window (help-buffer) | 72 | ;; expects (current-buffer) to be a help buffer when processing |
| 68 | (prin1 function) | 73 | ;; those buttons, so we can't change the current buffer before |
| 69 | ;; Use " is " instead of a colon so that | 74 | ;; calling that. |
| 70 | ;; it is easier to get out the function name using forward-sexp. | 75 | (let ((describe-function-orig-buffer |
| 71 | (princ " is ") | 76 | (or describe-function-orig-buffer |
| 72 | (describe-function-1 function) | 77 | (current-buffer)))) |
| 73 | (with-current-buffer standard-output | 78 | |
| 74 | ;; Return the text we displayed. | 79 | (help-setup-xref |
| 75 | (buffer-string))))) | 80 | (list (lambda (function buffer) |
| 81 | (let ((describe-function-orig-buffer | ||
| 82 | (if (buffer-live-p buffer) buffer))) | ||
| 83 | (describe-function function))) | ||
| 84 | function describe-function-orig-buffer) | ||
| 85 | (called-interactively-p 'interactive)) | ||
| 86 | |||
| 87 | (save-excursion | ||
| 88 | (with-help-window (help-buffer) | ||
| 89 | (prin1 function) | ||
| 90 | ;; Use " is " instead of a colon so that | ||
| 91 | ;; it is easier to get out the function name using forward-sexp. | ||
| 92 | (princ " is ") | ||
| 93 | (describe-function-1 function) | ||
| 94 | (with-current-buffer standard-output | ||
| 95 | ;; Return the text we displayed. | ||
| 96 | (buffer-string)))) | ||
| 97 | )) | ||
| 76 | 98 | ||
| 77 | 99 | ||
| 78 | ;; Could be this, if we make symbol-file do the work below. | 100 | ;; Could be this, if we make symbol-file do the work below. |