1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-05-10 15:25:04 -07:00

New variable 'completion-preview-is-calling'

* lisp/completion-preview.el (completion-preview-is-calling):
New variable.
(completion-preview--capf-wrapper): Bind it to t when calling
the CAPF.
* etc/NEWS: Announce it.
This commit is contained in:
Eshel Yaron 2026-04-30 21:19:19 +02:00
parent b54cde9119
commit a24ff52a79
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618
2 changed files with 17 additions and 1 deletions

View file

@ -4489,6 +4489,11 @@ the minibuffer, instead of waiting with 'sit-for' and then clearing it.
This makes 'minibuffer-message' usable in Lisp programs which want to
print a message and then continue to perform work.
---
** New variable 'completion-preview-is-calling'.
Completion functions (in 'completion-at-point-functions') can check this
variable to tell if they are being called by Completion Preview mode.
** Special Events
+++

View file

@ -523,9 +523,20 @@ candidates or if there are multiple matching completions and
(setq sorted (cdr sorted)))
(list (substring string 0 base) common suffixes))))))
(defvar completion-preview-is-calling nil
"Non-nil while Completion Preview mode is calling a completion function.
Completion functions (in `completion-at-point-functions') can check this
variable and adjust their behavior for completion preview.
For example, a completion function can skip calculating annotations for
candidates it produces for display in the completion preview, which does
not make use of such annotations.")
(defun completion-preview--capf-wrapper (capf)
"Translate return value of CAPF to properties for completion preview overlay."
(let ((res (ignore-errors (funcall capf))))
(let ((res (ignore-errors
(let ((completion-preview-is-calling t))
(funcall capf)))))
(and (consp res)
(not (functionp res))
(seq-let (beg end table &rest plist) res