hydra.el (hydra--hint-from-matrix): Return a list

master
Oleh Krehel 7 years ago
parent 1dab16cd2a
commit 38a567fc5b
  1. 21
      hydra.el

@ -578,12 +578,11 @@ BODY, and HEADS are parameters to `defhydra'."
(hydra--hint-from-matrix body (hydra--generate-matrix heads-w-col)))) (hydra--hint-from-matrix body (hydra--generate-matrix heads-w-col))))
(hint-wo-col (when heads-wo-col (hint-wo-col (when heads-wo-col
(hydra--hint-heads-wocol body (car heads-wo-col))))) (hydra--hint-heads-wocol body (car heads-wo-col)))))
(if (or (stringp hint-wo-col) (null hint-wo-col)) (if (null hint-w-col)
(concat hint-w-col hint-wo-col) hint-wo-col
(cl-assert (or (eq (car hint-wo-col) 'concat))) (if (stringp hint-wo-col)
(if hint-w-col `(concat ,@(cdr hint-w-col) ,hint-wo-col)
`(concat ,hint-w-col ,@(cdr hint-wo-col)) `(concat ,@(cdr hint-w-col) ,@(cdr hint-wo-col))))))
hint-wo-col))))
(defvar hydra-fontify-head-function nil (defvar hydra-fontify-head-function nil
"Possible replacement for `hydra-fontify-head-default'.") "Possible replacement for `hydra-fontify-head-default'.")
@ -744,10 +743,13 @@ The expressions can be auto-expanded according to NAME."
((string= docstring "") ((string= docstring "")
rest) rest)
((listp rest) ((listp rest)
(unless (string-match-p "[:\n]" docstring)
(setq docstring (concat docstring ":\n")))
(unless (or (string-match-p "\n\\'" docstring) (unless (or (string-match-p "\n\\'" docstring)
(equal (cadr rest) "\n")) (equal (cadr rest) "\n"))
(setq docstring (concat docstring "\n"))) (setq docstring (concat docstring "\n")))
`(concat (format ,docstring ,@(nreverse varlist)) ,@(cdr rest))) `(concat (format ,(replace-regexp-in-string "\\`\n" "" docstring) ,@(nreverse varlist))
,@(cdr rest)))
((eq ?\n (aref docstring 0)) ((eq ?\n (aref docstring 0))
`(format ,(concat (substring docstring 1) rest) ,@(nreverse varlist))) `(format ,(concat (substring docstring 1) rest) ,@(nreverse varlist)))
(t (t
@ -1136,8 +1138,9 @@ Each heads must have the same length
Each head must have a property max-key-len and max-doc-len." Each head must have a property max-key-len and max-doc-len."
(when heads-matrix (when heads-matrix
(let ((lines (hydra--hint-from-matrix-1 body heads-matrix))) (let ((lines (hydra--hint-from-matrix-1 body heads-matrix)))
(apply #'concat `(concat
`(,@(apply #'append (hydra-interpose '("\n") lines)) "\n"))))) ,@(apply #'append (hydra-interpose '("\n") lines))
"\n"))))
(defun hydra--hint-from-matrix-1 (body heads-matrix) (defun hydra--hint-from-matrix-1 (body heads-matrix)
(let* ((first-heads-col (nth 0 heads-matrix)) (let* ((first-heads-col (nth 0 heads-matrix))

Loading…
Cancel
Save