diff options
| author | Stephen Leake | 2015-08-15 12:17:47 -0500 |
|---|---|---|
| committer | Stephen Leake | 2015-08-15 12:18:47 -0500 |
| commit | 2ff8791d61b81a72b8c7d288ebcd352b696584a7 (patch) | |
| tree | 5c657d1964e71b7bd527712e93880075a25357ac | |
| parent | b6d4bafa1de2aa3ae2bb8cba5825d4a6f248ed0a (diff) | |
| download | emacs-2ff8791d61b81a72b8c7d288ebcd352b696584a7.tar.gz emacs-2ff8791d61b81a72b8c7d288ebcd352b696584a7.zip | |
Allow describe-function helpers to access buffer-local values.
This will be used by cedet/mode-local.el `describe-mode-local-override'
on `help-fns-describe-function-functions' in upstream CEDET.
* lisp/help-fns.el (describe-function-orig-buffer): New, let-bound in
`describe-function'.
(describe-function): Bind it, save it on the help xref stack.
| -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. |