Function: gptel--restore-props
gptel--restore-props is a natively compiled function defined in
gptel.el.
Signature
(gptel--restore-props BOUNDS-ALIST)
Documentation
Restore text properties from BOUNDS-ALIST.
BOUNDS-ALIST is (PROP . BOUNDS). BOUNDS is a list of BOUND. Each BOUND is either (BEG END VAL) or (BEG END).
For (BEG END VAL) forms, even if VAL is nil, the gptel property will be set to (PROP . VAL). For (BEG END) forms, except when PROP is response, the gptel property is set to just PROP.
The legacy structure, a list of (BEG . END) is also supported and will be applied before being re-persisted in the new structure.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
;;; Saving and restoring state
(defun gptel--restore-props (bounds-alist)
"Restore text properties from BOUNDS-ALIST.
BOUNDS-ALIST is (PROP . BOUNDS). BOUNDS is a list of BOUND. Each BOUND
is either (BEG END VAL) or (BEG END).
For (BEG END VAL) forms, even if VAL is nil, the gptel property will be
set to (PROP . VAL). For (BEG END) forms, except when PROP is response,
the gptel property is set to just PROP.
The legacy structure, a list of (BEG . END) is also supported and will be
applied before being re-persisted in the new structure."
;; Run silently to avoid `gptel--inherit-stickiness' and other hooks that
;; might modify the gptel text property.
(with-silent-modifications
(if (symbolp (caar bounds-alist))
(mapc
(lambda (bounds)
(let* ((prop (pop bounds)))
(mapc
(lambda (bound)
(let ((prop-has-val (> (length bound) 2)))
(add-text-properties
(pop bound) (pop bound)
(if (eq prop 'response)
'(gptel response front-sticky (gptel))
(list 'gptel
(if prop-has-val
(cons prop (pop bound))
prop))))))
bounds)))
bounds-alist)
(mapc (lambda (bound)
(add-text-properties
(car bound) (cdr bound) '(gptel response front-sticky (gptel))))
bounds-alist))))