Fork me on GitHub
#clerk
<
2024-02-01
>
phronmophobic18:02:03

I was trying to set things up so that all results are shown except for the results from defn, but couldn't figure it out. More info in 🧵

phronmophobic18:02:36

Here's what I tried:

(def var-viewer
  {:pred (fn [o]
           (or (var? o)
               (fn? o)))
   :transform-fn (fn [_]
                   nil)})

(clerk/reset-viewers!
 (into [var-viewer]
       (remove #{v/var-viewer
                 v/var-from-def-viewer})
       v/default-viewers))

{:nextjournal.clerk/visibility {:code :hide :result :show}}

(defn my-fn [])

(+ 1 2)
The goal is for 3 to show up for the (+ 1 2) expression, but to prevent #function[wikiart/my-fn] from showing up for (defn my-fn []).

mkvlr18:02:06

with the latest version on main the example at the bottom of https://github.com/nextjournal/clerk/blob/main/notebooks/viewers/context.clj should work

👀 1
👍 1
phronmophobic18:02:44

I have a workaround so I'll probably stick with that until an official release. I just wanted to check to see if I was doing something dumb.

mkvlr18:02:50

yeah it’s still cutting edge and undocumented since we’re not happy with the naming yet

👍 1