branch: externals/hydra commit 3846e2728f2a7bffa1b1116479426b2ab3c40a28 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
hydra.el (hydra-interpose): Extract --- hydra.el | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/hydra.el b/hydra.el index b1d4bd52b9..61f92ec2f4 100644 --- a/hydra.el +++ b/hydra.el @@ -1103,17 +1103,28 @@ representing the maximum dimension of their owning group. decorated-heads) res))) (nreverse res)))) +(defun hydra-interpose (x lst) + "Insert X in between each element of LST." + (let (res y) + (while (setq y (pop lst)) + (push y res) + (push x res)) + (nreverse (cdr 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 "| "))) + (let ((lst (hydra-interpose + "| " + (mapcar (lambda (head) + (funcall hydra-key-doc-function + (hydra-fontify-head head body) + (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)))) + (replace-regexp-in-string + "\s+$" "" + (apply #'concat lst)))) (defun hydra--hint-from-matrix (body heads-matrix) "Generate a formated table-style docstring according to BODY and HEADS-MATRIX.