This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aleph (5)
- # announcements (1)
- # architecture (35)
- # babashka (9)
- # beginners (87)
- # chlorine (13)
- # cider (3)
- # cljdoc (12)
- # clojure (16)
- # clojure-australia (2)
- # clojure-dev (4)
- # clojure-europe (5)
- # clojuredesign-podcast (21)
- # clojurescript (19)
- # conjure (1)
- # core-async (1)
- # crux (5)
- # data-science (1)
- # emacs (44)
- # events (2)
- # helix (1)
- # leiningen (2)
- # malli (31)
- # pathom (3)
- # pedestal (31)
- # portal (3)
- # reagent (20)
- # reitit (5)
- # reveal (2)
- # rewrite-clj (18)
- # tools-deps (6)
on the topic of rich comments containing tests, i have been using this a bit: https://github.com/sogaiu/alc.x-as-tests one can put simple tests within rich comments like this:
there is a "runner" mode which can execute these tests
(comment (- 1 1) ;; => 0 ,)
@UG1C3AD5Z That's neat! I could see that being useful for simple tests or getting some tests going quickly. Do you use code folding in your development environment? One of the reasons why I created separate "fiddle" files was to get the non-production code into its own place.
This is interesting. Reminds me of Stuart Halloway's https://github.com/cognitect-labs/transcriptor
OMG. I just learned how I could use commas to keep that last paren on a separate line!!! 🎉
@U5FV4MJHG indeed i do use code-folding for comment blocks when using emacs. still trying to get that to work well in neovim but haven't had much luck there 🙂 fwiw, in emacs i do something like:
(add-hook 'clojure-mode-hook (lambda () (hs-minor-mode) (setq hs-hide-comments-when-hiding-all nil) (setq hs-block-start-regexp "\\s(comment")))
@nate yes, this definitely takes inspiration from stuart halloway's transcriptor. i don't know if you've taken a look at mal, but i just noticed in the last few days that its test files do something similar.
@U6VPZS1EK i learned about the "door stop" technique in #parinfer -- though there folks were using other constructs such as
 to achieve the same end.
i have been collecting good uses for the comma in clojure -- it appears it's got more to it than at first glance.
this particular use of "preventing the editor from moving things around" i also use for formatting part of
cond forms and a few other places.
@U5FV4MJHG ah i forgot to mention -- one of my ulterior motives is to try to get simple / illustrative uses to live close to definitions. so i decided to try having the examples / tests live in the same file as the definitions. i'm not trying to have a comprehensive testing system -- it's supposed to be light and informative. geared toward explorative phases of development. i wrote a version for the janet programming language first before making a port to clojure. in both implementations, separate files are generated containing tests and these can be used as a starting point for more traditional testing if desired.
@UG1C3AD5Z I have folding working in neovim. I'll dig up the proper config bits when I'm at my terminal again.
@UG1C3AD5Z I use https://github.com/gberenfield/cljfold.vim, with this in my vimrc:
let g:clojure_foldwords = "def,defn,defmacro,defmethod,defschema,defprotocol,defrecord"
@nate thanks! i gave that a try using "comment" as the value. unfortunately, the fold somehow seems to "swallow" defns that follow comment blocks. fwiw, here is a relatively minimal section of code that demos it here:
any ideas about this? (it also seems to match on "comment-block?" which by sheer coincidence happened to be in the file i tested.)
(ns my.ns) (comment (+ 1 1) ;; => ) (defn my-fn  :my-value)
the extra line did it! thanks 🙂 on a side note, i've been looking at nvim-treesitter recently. they seem to have plans for some folding, so perhaps there will be other options before long.
for any interested parties, i jotted down some of the situations i've found the comma to be useful in: https://gist.github.com/sogaiu/d8d2b9765bef37f645211d4d5df1d7c8 happy to hear about other uses too :)
@UG1C3AD5Z I like your idea of putting illustrative uses of a function near to the function. That is indeed handy. @U0510902N is definitely more hooked on code folding than I am, but I can see how folding helps to eliminate some of the visual noise associated with mixing the function code and the example code.
i haven't found anything other than folding so far, but perhaps there are other alternatives (or will be at some point). at the moment i'm happy at least this option exists 🙂 on a side note, i've also experimented with applying folding to long strings such as docstrings. i'm usually grateful for docstrings those but also find that those can interfere with my code reading process sometimes.