From: Daniel Mendler <mail@daniel-mendler.de>
To: 48738@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#48738: [PATCH] Optimized `describe-variable' predicate
Date: Sun, 30 May 2021 06:27:16 +0200 [thread overview]
Message-ID: <55a7f6fc-ccad-a8e3-2f51-1cbc1555a4f8@daniel-mendler.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
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.
Ideally there would be a `buffer-local-boundp` predicate we could use
here.
In GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version
3.24.5, cairo version 1.16.0)
of 2021-05-23 built on projects
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)
[-- Attachment #2: 0001-describe-variable-Do-not-switch-to-the-original-buff.patch --]
[-- Type: text/x-diff, Size: 1877 bytes --]
From 9100bce6f057787df9f255a9bb98f37bbef44940 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
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
next reply other threads:[~2021-05-30 4:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-30 4:27 Daniel Mendler [this message]
2021-05-31 4:55 ` bug#48738: [PATCH] Optimized `describe-variable' predicate Lars Ingebrigtsen
2021-05-31 5:00 ` Daniel Mendler
2021-05-31 5:06 ` Lars Ingebrigtsen
2021-05-31 5:13 ` Lars Ingebrigtsen
2021-05-31 5:19 ` Daniel Mendler
2021-05-31 5:23 ` Lars Ingebrigtsen
2021-05-31 5:30 ` Daniel Mendler
2021-05-31 5:32 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55a7f6fc-ccad-a8e3-2f51-1cbc1555a4f8@daniel-mendler.de \
--to=mail@daniel-mendler.de \
--cc=48738@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.