Function: hydra--generate-matrix
hydra--generate-matrix is a byte-compiled function defined in
hydra.el.
Signature
(hydra--generate-matrix HEADS-GROUPS)
Documentation
Return a copy of HEADS-GROUPS decorated with table formatting information.
Details of modification:
2 virtual heads acting as table header were added to each heads-group.
Each head is decorated with 2 new properties max-doc-len and max-key-len
representing the maximum dimension of their owning group.
Every heads-group have equal length by adding padding heads where applicable.
Source Code
;; Defined in ~/.emacs.d/elpa/hydra-20250316.1254/hydra.el
(defun hydra--generate-matrix (heads-groups)
"Return a copy of HEADS-GROUPS decorated with table formatting information.
Details of modification:
2 virtual heads acting as table header were added to each heads-group.
Each head is decorated with 2 new properties max-doc-len and max-key-len
representing the maximum dimension of their owning group.
Every heads-group have equal length by adding padding heads where applicable."
(when heads-groups
(let ((res nil))
(dolist (heads-group (hydra--pad-heads heads-groups '(" " nil " " :exit t)))
(let* ((column-name (hydra--head-property (nth 0 heads-group) :column))
(max-key-len (apply #'max (mapcar (lambda (x) (length (car x))) heads-group)))
(max-doc-len (apply #'max
(length column-name)
(mapcar (lambda (x) (length (hydra--to-string (nth 2 x)))) heads-group)))
(header-virtual-head `(" " nil ,column-name :column ,column-name :exit t))
(separator-virtual-head `(" " nil ,(make-string (+ 2 max-doc-len max-key-len) ?-) :column ,column-name :exit t))
(decorated-heads (copy-tree (apply 'list header-virtual-head separator-virtual-head heads-group))))
(push (mapcar (lambda (it)
(hydra--head-set-property it :max-key-len max-key-len)
(hydra--head-set-property it :max-doc-len max-doc-len))
decorated-heads) res)))
(nreverse res))))