From 9100bce6f057787df9f255a9bb98f37bbef44940 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 30 May 2021 06:16:17 +0200 Subject: [PATCH] (describe-variable): Do not switch to the original buffer in the predicate Do not switch to the original buffer. Use `buffer-local-value` instead. The buffer switching is more costly, which slows down continuously updating completion UIs like Icomplete or Vertico if there are many variables. * lisp/help-fns.el (describe-variable): Use optimized predicate. --- lisp/help-fns.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 0b0ae4364c..46ace6bd24 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1022,12 +1022,14 @@ describe-variable (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 exists in + ;; the original buffer, we have to look for + ;; it there. + (ignore-errors + (or (buffer-local-value vv orig-buffer) + t))))) t nil nil (if (symbolp v) (symbol-name v)))) (list (if (equal val "") -- 2.20.1