commit a18eff2b2fa0980126e2884f119791a2cf31231e parent 582e167528628762fb8692cc841e3b0eba88ecdb Author: Wilfred Hughes <me@wilfred.me.uk> Date: Sat, 22 Jul 2017 12:47:22 +0100 Format quotes in macro calls Diffstat:
| M | helpful.el | | | 6 | +++++- |
| M | test/unit-test.el | | | 10 | ++++++++++ |
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/helpful.el b/helpful.el @@ -387,8 +387,12 @@ E.g. (x x y z y) -> ((x . 2) (y . 2) (z . 1))" (defun helpful--format-reference (head ref-count position path) (-let* (((def name) head) + (formatted-name + (if (and (consp name) (eq (car name) 'quote)) + (format "'%S" (cadr name)) + (format "%S" name))) (formatted-def - (format "(%s %s ...)" def name)) + (format "(%s %s ...)" def formatted-name)) (padded-def (s-pad-right 30 " " formatted-def)) (formatted-count diff --git a/test/unit-test.el b/test/unit-test.el @@ -70,3 +70,13 @@ ;; But if we have a single sentence and no empy line, insert one. (should (equal (helpful--split-first-line "foo.\nbar") "foo.\n\nbar"))) + +(ert-deftest helpful--format-reference () + (should + (equal + (helpful--format-reference '(def foo) 1 123 "/foo/bar.el") + "(def foo ...) ; 1 reference")) + (should + (equal + (helpful--format-reference '(advice-add 'bar) 1 123 "/foo/bar.el") + "(advice-add 'bar ...) ; 1 reference")))