emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hydra 67098cc914 22/46: hydra.el (hydra--format): Add e


From: Stefan Monnier
Subject: [elpa] externals/hydra 67098cc914 22/46: hydra.el (hydra--format): Add extra newline
Date: Tue, 25 Oct 2022 22:27:21 -0400 (EDT)

branch: externals/hydra
commit 67098cc9149854a95b589c3763843eabc82c9b2d
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    hydra.el (hydra--format): Add extra newline
    
    * hydra-test.el (hydra-columns-2): Add test.
    
    Fixes #306
---
 hydra-test.el | 23 +++++++++++++++++++++++
 hydra.el      |  8 +++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/hydra-test.el b/hydra-test.el
index 7d9d90887e..4e77b7ade0 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -1466,6 +1466,29 @@ t: info-to"
                    314 315 (face hydra-face-blue)
                    322 323 (face hydra-face-blue)))))
 
+(ert-deftest hydra-columns-2 ()
+  (should (equal (eval
+                  (cadr
+                   (nth 2
+                        (nth 3
+                             (macroexpand
+                              '(defhydra hydra-foo (:color blue)
+                                "Silly hydra"
+                                ("x" forward-char "forward" :column "sideways")
+                                ("y" backward-char "back")
+                                ("a" next-line "down" :column "vertical")
+                                ("b" previous-line "up")))))))
+                 #("Silly hydra:
+sideways    | vertical
+----------- | -----------
+x: forward  | a: down
+y: back     | b: up
+"
+                   62 63 (face hydra-face-blue)
+                   76 77 (face hydra-face-blue)
+                   84 85 (face hydra-face-blue)
+                   98 99 (face hydra-face-blue)))))
+
 ;; checked:
 ;; basic rendering
 ;; column compatibility with ruby style and no colum specified
diff --git a/hydra.el b/hydra.el
index e738b18d70..49066e9bd2 100644
--- a/hydra.el
+++ b/hydra.el
@@ -724,7 +724,13 @@ The expressions can be auto-expanded according to NAME."
         (t
          (let ((r `(replace-regexp-in-string
                     " +$" ""
-                    (concat ,docstring ": "
+                    (concat ,docstring
+                            ,(cond ((string-match-p "\\`\n" rest)
+                                    ":")
+                                   ((string-match-p "\n" rest)
+                                    ":\n")
+                                   (t
+                                    ": "))
                             (replace-regexp-in-string
                              "\\(%\\)" "\\1\\1" ,rest)))))
            (if (stringp rest)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]