Function: consult-register-format
consult-register-format is an autoloaded and byte-compiled function
defined in consult-register.el.
Signature
(consult-register-format REG &optional COMPLETION)
Documentation
Enhanced preview of register REG.
This function can be used as register-preview-function.
If COMPLETION is non-nil format the register for completion.
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult-register.el
;;;###autoload
(defun consult-register-format (reg &optional completion)
"Enhanced preview of register REG.
This function can be used as `register-preview-function'.
If COMPLETION is non-nil format the register for completion."
(pcase-let* ((`(,key . ,val) reg)
(key-str (propertize (single-key-description key) 'face 'consult-key))
(key-len (max 3 (length key-str)))
(`(,str . ,props) (consult-register--describe val)))
(when (string-search "\n" str)
(let* ((lines (seq-take (seq-remove #'string-blank-p (split-string str "\n")) 3))
(space (cl-loop for x in lines minimize (string-match-p "[^ ]" x))))
(setq str (mapconcat (lambda (x) (substring x space))
lines (concat "\n" (make-string (1+ key-len) ?\s))))))
(setq str (concat
(and completion consult-register-prefix)
key-str (make-string (- key-len (length key-str)) ?\s) " "
str (and (not completion) "\n")))
(when completion
(add-text-properties
0 (length str)
`(consult--candidate ,(car reg) ,@props)
str))
str))