diff options
author | Stephen Leake <stephen_leake@stephe-leake.org> | 2015-08-15 12:17:47 -0500 |
---|---|---|
committer | Stephen Leake <stephen_leake@stephe-leake.org> | 2015-08-15 12:18:47 -0500 |
commit | 2ff8791d61b81a72b8c7d288ebcd352b696584a7 (patch) | |
tree | 5c657d1964e71b7bd527712e93880075a25357ac | |
parent | b6d4bafa1de2aa3ae2bb8cba5825d4a6f248ed0a (diff) | |
download | emacs-2ff8791d61b81a72b8c7d288ebcd352b696584a7.tar.gz |
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.") ;; Functions +(defvar describe-function-orig-buffer nil + "Buffer that was current when 'describe-function' was invoked. +Functions on 'help-fns-describe-function-functions' can use this +to get buffer-local values.") + ;;;###autoload (defun describe-function (function) "Display the full documentation of FUNCTION (a symbol)." @@ -61,18 +66,35 @@ The functions will receive the function name as argument.") (user-error "You didn't specify a function symbol")) (or (fboundp function) (user-error "Symbol's function definition is void: %s" function)) - (help-setup-xref (list #'describe-function function) - (called-interactively-p 'interactive)) - (save-excursion - (with-help-window (help-buffer) - (prin1 function) - ;; Use " is " instead of a colon so that - ;; it is easier to get out the function name using forward-sexp. - (princ " is ") - (describe-function-1 function) - (with-current-buffer standard-output - ;; Return the text we displayed. - (buffer-string))))) + + ;; We save describe-function-orig-buffer on the help xref stack, so + ;; it is restored by the back/forward buttons. 'help-buffer' + ;; expects (current-buffer) to be a help buffer when processing + ;; those buttons, so we can't change the current buffer before + ;; calling that. + (let ((describe-function-orig-buffer + (or describe-function-orig-buffer + (current-buffer)))) + + (help-setup-xref + (list (lambda (function buffer) + (let ((describe-function-orig-buffer + (if (buffer-live-p buffer) buffer))) + (describe-function function))) + function describe-function-orig-buffer) + (called-interactively-p 'interactive)) + + (save-excursion + (with-help-window (help-buffer) + (prin1 function) + ;; Use " is " instead of a colon so that + ;; it is easier to get out the function name using forward-sexp. + (princ " is ") + (describe-function-1 function) + (with-current-buffer standard-output + ;; Return the text we displayed. + (buffer-string)))) + )) ;; Could be this, if we make symbol-file do the work below. |