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.
This commit is contained in:
Eshel Yaron 2026-05-05 11:08:53 +02:00
parent 288f8d0b05
commit 5789621632
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618

View file

@ -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)