<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cider on Ken Huang</title>
    <link>https://blog.kenhuang.io/tags/cider/</link>
    <description>Recent content in Cider on Ken Huang</description>
    <generator>Hugo</generator>
    <language>en</language>
    <managingEditor>whatacold@gmail.com (Ken Huang)</managingEditor>
    <webMaster>whatacold@gmail.com (Ken Huang)</webMaster>
    <lastBuildDate>Sat, 17 May 2025 05:15:47 +0800</lastBuildDate>
    <atom:link href="https://blog.kenhuang.io/tags/cider/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>🥷 Clojure Pro Tip 4: Cider ClojureDocs</title>
      <link>https://blog.kenhuang.io/blog/2025-04-29-clojure-tip-cider-clojuredocs/</link>
      <pubDate>Tue, 29 Apr 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-04-29-clojure-tip-cider-clojuredocs/</guid>
      <description>&lt;p&gt;&#xA;Sometimes, we may want a few examples of a Clojure API for inspiration while developing, especially when reading other people&amp;#39;s or open source code.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;With &lt;a href=&#34;https://cider.mx/&#34;&gt;Cider&lt;/a&gt; in &lt;a href=&#34;https://www.gnu.org/software/emacs/&#34;&gt;Emacs&lt;/a&gt;, we can run &lt;code class=&#34;verbatim&#34;&gt;M-x cider-doc&lt;/code&gt; to see the docstring for the symbol. We can even use &lt;code class=&#34;verbatim&#34;&gt;M-x cider-clojuredocs&lt;/code&gt; for some examples if the symbol is from the language core.&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-cider-clojuredocs.jpg&#34; alt=&#34;Running M-x cider-clojuredocs&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;Running M-x cider-clojuredocs&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;&#xA;I happened to find this command recently. I bet I was not the only one who didn&amp;#39;t know it, thus I&amp;#39;m sharing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Getting Started with Cider for Clojure Programming</title>
      <link>https://blog.kenhuang.io/blog/2024-12-22-getting-started-with-cider/</link>
      <pubDate>Sun, 22 Dec 2024 17:17:15 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-12-22-getting-started-with-cider/</guid>
      <description>&lt;p&gt;&#xA;Here is the outline for my cider tutorial on YouTube, covering basic things you need to know to get started with cider, and starting exploring the fun of clojure programming with the REPL-driven programming approach.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/evmRpr_DEBQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;&#xA;    &lt;/div&gt;&#xA;&lt;/p&gt;&#xA;&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;&#xA;&lt;h2 id=&#34;headline-1&#34;&gt;&#xA;Jack In to a REPL&#xA;&lt;/h2&gt;&#xA;&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;&#xA;&lt;dl&gt;&#xA;&lt;dt&gt;&#xA;C-c M-j (cider-jack-in-clj)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;start a nREPL and jack in.&#xA;&#xA;It works in a project or with a &lt;strong&gt;sole .clj file&lt;/strong&gt;.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;M-x cider-connect-clj&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;run the command and then fill in hostname and port.&#xA;&#xA;It could be useful in some cases. e.g. on Windows, I can start the nREPL manually and then connect to it separately.&lt;/dd&gt;&#xA;&lt;/dl&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;&#xA;&lt;h2 id=&#34;headline-2&#34;&gt;&#xA;Evaluate Things&#xA;&lt;/h2&gt;&#xA;&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;&#xA;&lt;dl&gt;&#xA;&lt;dt&gt;&#xA;C-M-x (cider-eval-defun-at-point)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate current top-level form.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-x C-e (cider-eval-last-sexp)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate the preceding form.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-c C-k (cider-load-buffer)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate/load the current buffer.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-c C-p (cider-pprint-eval-last-sexp)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;Pprint the result in a dedicated buffer.&#xA;&#xA;Great thing to do when the result is too large to fit in the echo area.&lt;/dd&gt;&#xA;&lt;/dl&gt;&#xA;&lt;p&gt;Note: I prefer to use the same key bindings as for Elisp, given that&#xA;cider might bind a few keys to a single command!&lt;/p&gt;</description>
    </item>
    <item>
      <title>A Few Quick Notes About babashka/fs</title>
      <link>https://blog.kenhuang.io/blog/2024-12-07-babashka-fs-notes/</link>
      <pubDate>Sat, 07 Dec 2024 22:24:41 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-12-07-babashka-fs-notes/</guid>
      <description>&lt;p&gt;&#xA;Recently I&amp;#39;ve used &lt;a href=&#34;https://github.com/babashka/fs/blob/master/API.md&#34;&gt;babashka/fs&lt;/a&gt; a little bit, here are some quick notes for it:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Path vs File.&#xA;&#xA;Use Path whenever possible, according to &lt;a href=&#34;https://stackoverflow.com/a/26658436&#34;&gt;this SO answer to &amp;#34;Java: Path vs File&amp;#34;&lt;/a&gt;.&#xA;&#xA;This is actually Java related.&lt;/li&gt;&#xA;&lt;li&gt;It&amp;#39;s ok to use a &lt;code class=&#34;verbatim&#34;&gt;path&lt;/code&gt; as a key for a clojure map.&#xA;&#xA;At my first try, I somehow came to the conclusion that it&amp;#39;s not ok, while I was refactoring the &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/src/scicloj/clay/v2/live_reload.clj&#34;&gt;live reload&lt;/a&gt; for clay. And later I found that it&amp;#39;s totally fine to use it as a key. 😞&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&#34;https://github.com/babashka/fs/blob/master/API.md#babashka.fs/path&#34;&gt;fs/path&lt;/a&gt; to construct file/directory paths, for example, &lt;code class=&#34;verbatim&#34;&gt;(fs/path &amp;#34;/tmp&amp;#34; &amp;#34;foo&amp;#34; &amp;#34;bar&amp;#34; &amp;#34;baz.clj&amp;#34;)&lt;/code&gt; will result in a path object for &lt;code class=&#34;verbatim&#34;&gt;/tmp/foo/bar/baz.clj&lt;/code&gt; on linux.&#xA;&#xA;If you&amp;#39;re coming from Python, it might remind you of &lt;a href=&#34;https://docs.python.org/3/library/os.path.html&#34;&gt;os.path.join(path, *paths)&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code class=&#34;verbatim&#34;&gt;fs/createdirs&lt;/code&gt; for &lt;code class=&#34;verbatim&#34;&gt;mkdir -p&lt;/code&gt;, though its name is a bit misleading, I first thought it&amp;#39;s for creating a few dirs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;fs/with-temp-dir&lt;/code&gt; is convenient for &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/test/scicloj/clay/v2/live_reload_test.clj&#34;&gt;creating tests&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Doing Unit test in Clojure Is Easy</title>
      <link>https://blog.kenhuang.io/blog/2024-11-27-clojure-unit-test/</link>
      <pubDate>Thu, 28 Nov 2024 23:10:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-27-clojure-unit-test/</guid>
      <description>&lt;p&gt;&#xA;While refactoring the &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/src/scicloj/clay/v2/live_reload.clj&#34;&gt;live reload&lt;/a&gt; feature of &lt;a href=&#34;https://github.com/scicloj/clay&#34;&gt;Clay&lt;/a&gt;, I realized I&amp;#39;d better break long functions into smaller and functional ones (as many as I can), which is also a &lt;a href=&#34;https://guide.clojure.style/#be-functional&#34;&gt;common practice&lt;/a&gt; in the clojure community.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Small pure functions not only are easy to verify on the development process (using a REPL), but also are easy to test. And unit tests are easy to write in clojure, just use &lt;code class=&#34;verbatim&#34;&gt;deftest&lt;/code&gt; from &lt;code class=&#34;verbatim&#34;&gt;clojure.test&lt;/code&gt;, a very basic one looks like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Starting a Clojure nREPL Manually for Cider</title>
      <link>https://blog.kenhuang.io/blog/2024-11-08-cider-clojure-repl-cmdline/</link>
      <pubDate>Fri, 08 Nov 2024 00:02:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-08-cider-clojure-repl-cmdline/</guid>
      <description>&lt;p&gt;&#xA;While troubleshooting and fixing a &lt;a href=&#34;https://github.com/scicloj/clay/issues/176&#34;&gt;live reload bug&lt;/a&gt; in &lt;a href=&#34;https://github.com/scicloj/clay&#34;&gt;Clay&lt;/a&gt; today, which required to start a minimal Clojure environment, I figured out how to start a nREPL from the command line.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Instead of using &lt;code class=&#34;verbatim&#34;&gt;M-x cider-jack-in-clj&lt;/code&gt; directly from Emacs, actually we can manully bring up an nREPL with this: &lt;code class=&#34;verbatim&#34;&gt;clj -Sdeps &amp;#34;{:deps {org.scicloj/clay {:mvn/version \&amp;#34;2-beta21\&amp;#34;} cider/cider-nrepl {:mvn/version \&amp;#34;0.50.2\&amp;#34;}}}&amp;#34; -m nrepl.cmdline --middleware &amp;#34;[cider.nrepl/cider-middleware]&amp;#34;&lt;/code&gt; (The clay part is only necessary for this debugging), and then connect to this nREPL using the Emacs command &lt;code class=&#34;verbatim&#34;&gt;M-x cider-connect-clj&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
