Function: marginalia--truncate
marginalia--truncate is a byte-compiled function defined in
marginalia.el.
Signature
(marginalia--truncate STR WIDTH)
Documentation
Truncate string STR to WIDTH.
Source Code
;; Defined in ~/.emacs.d/elpa/marginalia-20260724.810/marginalia.el
(defun marginalia--truncate (str width)
"Truncate string STR to WIDTH."
(when (floatp width) (setq width (round (* width marginalia-field-width))))
(when-let* ((pos (string-search "\n" str)))
(setq str (substring str 0 pos)))
(let* ((face (and (not (equal str ""))
(get-text-property (1- (length str)) 'face str)))
(ell (if face
(propertize (marginalia--ellipsis) 'face face)
(marginalia--ellipsis)))
(trunc
(if (< width 0)
(nreverse (truncate-string-to-width (reverse str) (- width) 0 ?\s ell))
(truncate-string-to-width str width 0 ?\s ell))))
(unless (string-prefix-p str trunc)
(put-text-property 0 (length trunc) 'help-echo str trunc))
trunc))