From 5789621632aab090ce2ef66a48a234a9505ddec2 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 5 May 2026 11:08:53 +0200 Subject: [PATCH] elisp-mode: Cache 'help-echo' function results (bug#80948) This ensures we only compute the 'help-echo' string once per symbol in a certain position. * lisp/progmodes/elisp-mode.el (elisp--annotate-symbol-with-help-echo): Add caching for when the symbol role's :help property is a function. --- lisp/progmodes/elisp-mode.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 64ff21e3578..8dab8d57ec3 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -575,7 +575,12 @@ This option has effect only if `elisp-fontify-semantically' is non-nil." ;; HLP is either a string, or a function that takes SYM as an ;; additional argument on top of the usual WINDOW, OBJECT and POS ;; that `help-echo' functions takes. - (if (stringp hlp) hlp (apply-partially hlp sym))))) + (if (stringp hlp) hlp + (let ((cache 'unset)) + (lambda (win obj pos) + (if (eq cache 'unset) + (setq cache (funcall hlp sym win obj pos)) + cache))))))) (defvar font-lock-beg) (defvar font-lock-end)