]> git.eshelyaron.com Git - emacs.git/commitdiff
Speed up `describe-variable' completion predicate
authorDaniel Mendler <mail@daniel-mendler.de>
Mon, 31 May 2021 04:49:37 +0000 (06:49 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 31 May 2021 04:49:37 +0000 (06:49 +0200)
* lisp/help-fns.el (describe-variable): Do not switch to the original
buffer in the predicate (bug#48738).

lisp/help-fns.el

index 666583db72c6370a2099d77d6424737a686d4556..c8f078cb852880ae6fdd4e3b455f7babc4988dee 100644 (file)
@@ -1024,12 +1024,15 @@ it is displayed along with the global value."
                 (format-prompt "Describe variable" (and (symbolp v) v))
                 #'help--symbol-completion-table
                 (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))))))
+                  (or (get vv 'variable-documentation)
+                      (and (not (keywordp vv))
+                           ;; Since the variable may only exist in the
+                           ;; original buffer, we have to look for it
+                           ;; there.
+                           (condition-case nil
+                               (buffer-local-value vv orig-buffer)
+                             (:success t)
+                             (void-variable nil)))))
                 t nil nil
                 (if (symbolp v) (symbol-name v))))
      (list (if (equal val "")