This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-31
Channels
- # announcements (22)
- # asami (19)
- # aws-lambda (4)
- # babashka (42)
- # beginners (43)
- # calva (28)
- # cider (1)
- # clerk (79)
- # clj-kondo (12)
- # clojure (47)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dev (12)
- # clojure-europe (40)
- # clojure-nl (2)
- # clojure-norway (5)
- # clojure-uk (3)
- # clojurescript (56)
- # clr (12)
- # conjure (8)
- # cursive (4)
- # datomic (78)
- # dev-tooling (6)
- # exercism (1)
- # fulcro (9)
- # hoplon (3)
- # jobs (3)
- # jobs-discuss (4)
- # lambdaisland (3)
- # leiningen (1)
- # london-clojurians (1)
- # lsp (125)
- # malli (32)
- # matcher-combinators (3)
- # nrepl (1)
- # off-topic (6)
- # pathom (39)
- # re-frame (13)
- # releases (2)
- # remote-jobs (3)
- # sci (7)
- # shadow-cljs (117)
- # sql (6)
- # squint (7)
- # tools-build (15)
- # tools-deps (12)
I'm wondering if there's an alternative way to allow set!
to work on vars. I just wrote this middleware that I can call from user.clj, otherwise:
(ns io.dominic.nrepl-bind
(:require
[nrepl.middleware :as middleware :refer [set-descriptor!]]))
(def ^:private bind-vars (atom #{}))
(defn add-bound-var
[var]
(swap! bind-vars conj var)
nil)
(defmacro try-bind-vars
[& syms]
`(run! add-bound-var (keep requiring-resolve (quote ~syms))))
;; the handler
(defn- wrap-bind
[h]
(fn [{:keys [session] :as msg}]
(swap!
session
(fn [session]
(reduce
(fn [session var]
(cond-> session
(not (contains? session var))
(assoc var @var)))
session
@bind-vars)))
(h msg)))
(set-descriptor! #'wrap-bind {:requires #{"clone"}})