emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master db91108: Speed up `describe-variable' completion predicate


From: Lars Ingebrigtsen
Subject: master db91108: Speed up `describe-variable' completion predicate
Date: Mon, 31 May 2021 00:56:25 -0400 (EDT)

branch: master
commit db91108315016875ae912c0cbd6ccde563511b19
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Speed up `describe-variable' completion predicate
    
    * lisp/help-fns.el (describe-variable): Do not switch to the original
    buffer in the predicate (bug#48738).
---
 lisp/help-fns.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 666583d..c8f078c 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -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 "")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]