branch: externals/hydra commit 16563fbc4cfb05c9f40b0aa04a4ff10bb7de8a31 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
hydra.el (hydra--hint-row): Extract --- hydra.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hydra.el b/hydra.el index 1ccb483209..b1d4bd52b9 100644 --- a/hydra.el +++ b/hydra.el @@ -1103,6 +1103,18 @@ representing the maximum dimension of their owning group. decorated-heads) res))) (nreverse res)))) +(defun hydra--hint-row (heads body) + (replace-regexp-in-string + "\s+$" "" + (mapconcat (lambda (head) + (funcall hydra-key-doc-function + (hydra-fontify-head head body) ;; key + (let ((n (hydra--head-property head :max-key-len))) + (+ n (cl-count ?% (car head)))) + (nth 2 head) ;; doc + (hydra--head-property head :max-doc-len))) + heads "| "))) + (defun hydra--hint-from-matrix (body heads-matrix) "Generate a formated table-style docstring according to BODY and HEADS-MATRIX. HEADS-MATRIX is expected to be a list of heads with following features: @@ -1116,16 +1128,7 @@ Each head must have a property max-key-len and max-doc-len." (let ((heads-in-row (mapcar (lambda (heads) (nth row-index heads)) heads-matrix))) - (push (replace-regexp-in-string - "\s+$" "" - (mapconcat (lambda (head) - (funcall hydra-key-doc-function - (hydra-fontify-head head body) ;; key - (let ((n (hydra--head-property head :max-key-len))) - (+ n (cl-count ?% (car head)))) - (nth 2 head) ;; doc - (hydra--head-property head :max-doc-len))) - heads-in-row "| ")) + (push (hydra--hint-row heads-in-row body) lines))) (concat (mapconcat #'identity (nreverse lines) "\n") "\n"))))