This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-05
Channels
- # announcements (15)
- # aws (7)
- # babashka (105)
- # beginners (35)
- # biff (5)
- # calva (48)
- # cider (5)
- # clj-kondo (25)
- # cljdoc (14)
- # clojure (84)
- # clojure-czech (2)
- # clojure-dev (6)
- # clojure-europe (58)
- # clojure-nl (6)
- # clojure-norway (19)
- # clojure-portugal (2)
- # clojure-uk (5)
- # clojurescript (23)
- # cloverage (5)
- # code-reviews (5)
- # conjure (28)
- # data-science (1)
- # datomic (53)
- # events (6)
- # exercism (7)
- # fulcro (16)
- # graalvm-mobile (2)
- # honeysql (29)
- # improve-getting-started (2)
- # kaocha (32)
- # lambdaisland (2)
- # lsp (29)
- # malli (3)
- # overtone (1)
- # pedestal (8)
- # polylith (3)
- # portal (6)
- # quil (2)
- # rdf (15)
- # releases (2)
- # rewrite-clj (14)
- # sci (9)
- # shadow-cljs (7)
- # specter (5)
- # sql (5)
- # xtdb (38)
How do other Conjure users handle throwaway or testing forms? For example, when I test functions, I end up re-evaluating the function with a certain set of arguments repeatedly as I evolve or test it. I realize I can do :ConjureEval
. but that's not super convenient for editing. You can also add commented-out forms but those can easily get committed by mistake and clutter diffs.
One solution I like is having a repl_sessions
directory with useful snippets for experimenting (example: https://github.com/lambdaisland/kaocha/tree/main/repl_sessions). Another good option is writing tests, especially if you have tests set up to run whenever you save a file. I'd be curious to know what other ideas people have.
Most of the time, I just do the comment
form thing. I've developed a rigor around being careful what I commit. I always review git status
and git diff
before staging, and I have git configured to show me what I'm about to commit when I use git commit
to type in the commit message.
I also use https://github.com/airblade/vim-gitgutter, which makes it visually obvious right there in Vim what changes I've made since the last commit.
For projects where I'm writing a lot more scratch code, I make a "scratch" or "user" file, and sometimes it even makes sense to exclude that file in the gitignore so that I don't have to worry about making sure I don't commit it.
Thanks! I should probably be more aware of what I'm actually committing in general. (I review diffs before merging a PR at least, but sometimes skip that step before committing.) The other issue I have with comment forms is that if I want to keep them around for multiple commits, I have to manually select chunks to commit. I guess a Git plugin might help with that.
I use https://github.com/jreybert/vimagit for that - works nicely!
Comment form and marks, using <leader>em
or whatever it is to evaluate at mark.
And I often commit the comment form into the business application as documentation.
wasn't it you @U0AHJUHJN that asked for them?
It's been so long ago, I don't remember exactly how it went down, but I do remember taking part in conversations about that feature. I may or may not have come up with it, I honestly forget 😄
I wrote about that awesome feature here: https://blog.djy.io/conjuring-clojure-in-vim-2020-edition/#casting-spells
I also have a comment form. I tend to mark a few test forms in it with ma
, mb
... and keep my cursor in the defn I'm working on. My localleader is ,
so I use ,er
to re-eval the root defn, then ,ema
, ,emb
... to run the test form. Ideally then the test forms turn into a deftest, then it becomes a combo of ,er
and ,tn
to eval tests in my current namespace.
re: scratch files, I've been playing with using vim-projectionist to jump to a scratch file. So if the main ns is /src/my/ns.clj
then the scratch is as /dev/ns_scratch.clj
(alongside eg. /dev/user.clj
. If it's a public project I gitignore the scratch files, but in private ones I sometimes commit this stuff since it can help teammates.
Ahh interesting. I've thought about something like projectionist.
I use vim-gitgutter
to keep track of changes in the various buffers, and then git-fugitive
when writing commits, in the mode that shows the whole diff when committing
Projectionist is a good reminder because otherwise I'd be tempted to write something from scratch and fall down a rabbit hole.
I like Signify for showing changed and modified lines myself because it supports Mercurial as well.
projectionist helps me avoid the weirdly strong ugh factor I have around setting up a new, properly-properly named scratch (or test) file ... wish I knew how to use it better.
❯ cat .projections.json
{
"src/*.clj": {
"alternate": "test/{}_test.clj",
"type": "source",
"template": [
"(ns {dot|hyphenate}",
" {open}:author \"David Harrigan\"{close}",
" (:require",
" [clojure.tools.logging :as log]))",
"",
"(set! *warn-on-reflection* true)",
"",
";; PRIVATE FUNCTIONS AND DEFINITIONS ↓",
"",
";; PUBLIC FUNCTIONS AND DEFINITIONS ↓",
""
]
},
"test/*_test.clj": {
"alternate": "src/{}.clj",
"type": "test",
"template": [
"(ns {dot|hyphenate}-test",
" {open}:author \"David Harrigan\"{close}",
" (:require",
" [expectations.clojure.test :as t :refer [defexpect expect expecting in more-> more-of]]",
" [{dot|hyphenate} :as sut]))",
"",
"(set! *warn-on-reflection* true)",
"",
";; PRIVATE FUNCTIONS AND DEFINITIONS ↓",
"",
";; PUBLIC FUNCTIONS AND DEFINITIONS ↓",
""
]
}
}