Skip to content

Commit

Permalink
Format quotes in macro calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Jul 22, 2017
1 parent 582e167 commit a18eff2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")))

0 comments on commit a18eff2

Please sign in to comment.