Function: eca-chat--propertize-only-first-word
eca-chat--propertize-only-first-word is a natively compiled function
defined in eca-chat-expandable.el.
Signature
(eca-chat--propertize-only-first-word STR &rest PROPERTIES)
Documentation
Return a new string propertizing PROPERTIES to the first word of STR.
If STR is empty or PROPERTIES is nil, return STR unchanged. Existing text properties on STR are preserved; only the first word gets the additional PROPERTIES. The first word is the substring up to the first space, tab, or newline.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-expandable.el
(defun eca-chat--propertize-only-first-word (str &rest properties)
"Return a new string propertizing PROPERTIES to the first word of STR.
If STR is empty or PROPERTIES is nil, return STR unchanged. Existing
text properties on STR are preserved; only the first word gets the
additional PROPERTIES. The first word is the substring up to the first
space, tab, or newline."
(if (or (string-empty-p str) (null properties))
str
(let* ((split-pos (or (string-match "[ \t\n]" str)
(length str)))
(first (substring str 0 split-pos))
(rest (substring str split-pos)))
;; Preserve existing properties on `first` (copied by `substring`)
;; and add/override with the provided PROPERTIES only for the first word.
(add-text-properties 0 (length first) properties first)
(concat first rest))))