Joost Diepenmaat
Joost Diepenmaat

Reputation: 17773

Folding parts of an s-expression - advice requested

I'm using clojure-mode and clojure.test/with-test, which looks like this:

(with-test
  (def... some expression defining a var)

  ;; comment for a test
  (is (= 0 (- 1 1)))
  (is ...))

Where the expressions following the first one in (with-test ...) are test cases for the first form. This is useful since it keeps tests close to their relevant code.

However, the list of test cases may be pretty long, obscuring the rest of the "real" code. I would love to have some way of hiding all of the test code in a buffer. Something like outline/org-mode's folding abilities:

(with-test
  (def some expression defining a var)
  ...)

Or even

(def some expression defining a var)

with some kind of marker to show there are hidden test cases.

The tricky part about this is that the (def...) form that I want to focus on is inside the (with-test ...) form that I want to hide.

I've looked around and as far as I can see I won't be able to make this work with outline-mode or hideshow-mode. I'm assuming I need some folding library that is expression-aware to get something like this to work. Does something like this already exist, am I thinking about this the wrong way, do you have any tips?

Update

I was able to make it work with hideshow. See the hs-hide-all-clojure-tests in my emacs config repo

Upvotes: 2

Views: 531

Answers (1)

Alex Ott
Alex Ott

Reputation: 87069

I believe, that you can use the HideShow package for this task, but you'll need to add some configuration so it will hide only tests...

Upvotes: 4

Related Questions