1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-06 07:31:13 -08:00

Make describe-variable look up the variable in the current buffer

* lisp/help-fns.el (describe-variable): Get the variable
definition in the buffer we were called from (in case it only
exists there) (bug#21252).
This commit is contained in:
Lars Ingebrigtsen 2016-05-01 00:08:52 +02:00
parent eeac7c5727
commit 032b051031

View file

@ -699,17 +699,23 @@ it is displayed along with the global value."
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
(orig-buffer (current-buffer))
val)
(setq val (completing-read (if (symbolp v)
(format
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
(lambda (vv)
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv)))))
t nil nil
(if (symbolp v) (symbol-name v))))
(setq val (completing-read
(if (symbolp v)
(format
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
(lambda (vv)
;; In case the variable only exists in the buffer
;; the command we switch back to that buffer before
;; we examine the variable.
(with-current-buffer orig-buffer
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv))))))
t nil nil
(if (symbolp v) (symbol-name v))))
(list (if (equal val "")
v (intern val)))))
(let (file-name)