Adding Clojure Dependencies from the Command Line

While debugging a live reload issue of Clay a few days ago, I learned from Markus Agwin that we can actually add dependencies on the fly from the command line, just like this: clj -Sdeps "{:deps {org.scicloj/clay {:mvn/version \"2-beta21\"}}}". Even better, we can add dependency from a Git repo and specify the commit hash: clj -Sdeps "{:deps {io.github.scicloj/clay {:git/url \"https://github.com/scicloj/clay.git\" :git/sha \"35a46541db66ae6b4e1af628b7c24c42d3be418f\"}}}", which is really helpful for experimenting and verifying things. [Read More]
Clojure  Tweet  clj 

Bitten by Lazy Sequence of map

While impletenting the live reload feature for Clay a few weeks ago, unfortunately, I was bitten by the laziness of map. It seems quite obvious we all know that its result is a lazy sequence, but I just can't help fall into the "trap". At that time I was adding a vector to keep track of all beholder instances watching file changes in user specified directories. So then when it's time to stop all the watchers, I used something like to achieve the goal: [Read More]

Anonymous Functions in Thread Macros

While adding the live reload feature to Clay, I encountered a problem of applying anonymous functions to thread macros. For example, below is a simple snippet trying to wrap the input directory as a vector with the help of thread macro, but surprisingly, it errors out. After some searching, I figured out that I need to put the anonymous function into another pair of parentheses: (-> "/tmp/" #(if (vector? %) % [%])) ;; => Syntax error (ClassCastException) compiling fn* at (simple4all. [Read More]

Start a Clojure nREPL in the Command Line for Cider

While troubleshooting and fixing a live reload bug in Clay today, which requires to start a minimal Clojure environment, I figured out how to start a nREPL from the command line. Instead of using M-x cider-jack-in-clj directly from Emacs, actually we can manully bring up an nREPL with this: clj -Sdeps "{:deps {org.scicloj/clay {:mvn/version \"2-beta21\"} cider/cider-nrepl {:mvn/version \"0.50.2\"}}}" -m nrepl.cmdline --middleware '[cider.nrepl/cider-middleware]' (The clay part is only necessary for this debugging), and then connect to this nREPL using the Emacs command M-x cider-connect-clj. [Read More]