]> git.eshelyaron.com Git - emacs.git/commitdiff
Make describe-variable look up the variable in the current buffer
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 30 Apr 2016 22:08:52 +0000 (00:08 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 30 Apr 2016 22:08:52 +0000 (00:08 +0200)
* 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).

lisp/help-fns.el

index e2cb9f82a1bba31d2c171b89fd27e92008e14697..e17586c28fe9a9747c9783079f4e75519a75481b 100644 (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)