This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-04
Channels
- # architecture (35)
- # babashka (1)
- # beginners (60)
- # biff (6)
- # cider (21)
- # clerk (14)
- # clojure (10)
- # clojure-europe (42)
- # clojure-nl (1)
- # clojure-norway (15)
- # clojure-sweden (6)
- # clojure-uk (12)
- # clojurescript (19)
- # community-development (1)
- # data-science (2)
- # datalevin (1)
- # datomic (22)
- # gratitude (1)
- # honeysql (1)
- # hyperfiddle (8)
- # introduce-yourself (5)
- # leiningen (12)
- # lsp (18)
- # off-topic (20)
- # overtone (6)
- # pedestal (5)
- # specter (5)
- # sql (12)
- # xtdb (2)
Continuing this conversation here at #C0617A8PQ.
Try setting cider-clojure-cli-aliases
to ":dev/reload"
Delete the code that touches cider-clojure-cli-global-options
, I think it's a confusing defcustom, it got deprecated and then introduced again
Do I need to explicitly add
io.github.tonsky/clj-reload {:mvn/version "0.7.1"}
to my project deps.edn
?
With @U04V70XH6’s https://github.com/seancorfield/deps-new?tab=readme-ov-file#create-an-application template, it seems that clj-reload
from my global ~/.config/clojure/deps.edn
is ignored...Yes you do need it Try the simplest thing first (adding it to the project's deps.edn), if it works, then experiment with a global setup


How can I tell emacs to reload my project definition after I change something in deps.edn
?
For example, after adding a dependency?
M-x sesman-restart
performs jack-in again in a given project
I don't use it a lot but I think it works correctly!
(clojure 1.12 has a new feature for deps reloading, for now I'd stick to what we know that works)
I wrote some elisp code that works. Pasting here just in case someone else find it useful.
(require 'projectile)
(require 'parseedn)
(defun get-project-root ()
"Get the root directory of the current project."
(if (projectile-project-p)
(projectile-project-root)
default-directory))
(defun extract-ns-default (deps-file)
"Extract the ns-default from the :run-x alias in deps.edn."
(with-temp-buffer
(insert-file-contents deps-file)
(goto-char (point-min))
(let* ((deps-data (parseedn-read-str (buffer-string)))
(aliases (gethash :aliases deps-data))
(run-x (gethash :run-x aliases)))
(gethash :ns-default run-x))))
(defun set-cider-repl-init-code ()
(let ((ns (extract-ns-default (concat (get-project-root) "deps.edn"))))
(if ns
(list (format "(in-ns '%s)" ns))
(list)))) ;; return an empty string if no namespace is found
;; Hook into CIDER's jack-in hook to set the init code dynamically
(with-eval-after-load 'cider
(setq cider-repl-init-code (set-cider-repl-init-code)))
This works with the assumption the deps.edn
file lives at the root of the project (found with projectile), and that it has a structure like:
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.3"}
io.github.tonsky/clj-reload {:mvn/version "0.7.1"}}
:aliases
{:run-m {:main-opts ["-m" "oscarvarto.hello-world"]}
:run-x {:ns-default oscarvarto.hello-world
:exec-fn greet
:exec-args {:name "Clojure"}}
:build {:deps {io.github.clojure/tools.build
{:mvn/version "0.10.3"}}
:ns-default build}
:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}}}}
(this was generated from the https://github.com/seancorfield/deps-new?tab=readme-ov-file#create-an-application)Thanks vemv
I wrote the code going backwards. Checked that the final
(with-eval-after-load 'cider
(setq cider-repl-init-code (set-cider-repl-init-code)))
worked first with a hard-coded namespace/ cider-repl-init-code, then checked the other functions, fixing one by one.
LLM helped me a bit, but a lot of suggestions were wrong. However, little by little, I could fix stuff, by checking the error messages and looking at the docs.I think this exercise helped me a lot. Hopefully I got a little bit more of understanding of what interactive development means.
Yes Emacs is a prime example of interactive development, and also of creating self-documenting systems Suerte con todo compadre


Could anybody take a look at my initialization code for CIDER nREPL, and suggest an improvement/fix? This is not working:
(defun set-cider-repl-init-code ()
(let ((ns (extract-ns-default (concat (get-project-root) "deps.edn"))))
(if ns
;;(list (format "(in-ns '%s)" ns)) ;; <== This works. But below initialization to load/require namespaces don't.
(list (format "(in-ns '%s)
(do (require '[clojure.core :as c]
'[clojure.repl :as r])
(println \"Required namespaces loaded.\"))
" ns))
(list)))) ;; return an empty string if no namespace is found
What does "not working" mean?
Try putting dummy code like (spit "a" "a")
, does it get run?
Anyone else running into problems with cider's docstring stuff breaking completions in emacs? Not sure if this is a bug or not. Ran into this using corfu with docs always displayed in corfu-popupinfo, but the problem was reproducible with :
1. emacs -Q
2. M-x package-install cider
3. I opened a clojure file, did cider-connect-clj
to a running repl
4. M-x toggle-debug-on-error
5. run complete-symbol with M-tab on a completion that includes a namespace or otherwise doesn't have its own docstring. Specifically I typed '(h' and hit M-tab
` a couple times
Backtrace
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
replace-regexp-in-string("\n " "\n" nil)
cider-docstring--format(nil)
cider-eldoc-format-variable("ha" ("ns" nil "class" nil "symbol" ".nil" "arglists" nil "docstring" nil "doc-fragments" nil "doc-first-sentence-fragments" nil "doc-block-tags-fragments" nil "type" "variable"))
cider-eldoc(#f(compiled-function (string &rest plist) #))
eldoc-documentation-default()
eldoc--invoke-strategy(nil)
eldoc-print-current-symbol-info()
#()
apply(# nil)
timer-event-handler([t 0 0 500000 nil # nil idle 0 nil])
emacs version is 29.4 on opensuse tumbleweedThere was nil fix for cider-docstring--format . Are you on cider master / latest unstable?
master, repl reads CIDER 1.15.1 (Cogne)
. Tried an older version too and got the same result.
Could anybody take a look at my initialization code for CIDER nREPL, and suggest an improvement/fix? This is not working:
(defun set-cider-repl-init-code ()
(let ((ns (extract-ns-default (concat (get-project-root) "deps.edn"))))
(if ns
;;(list (format "(in-ns '%s)" ns)) ;; <== This works. But below initialization to load/require namespaces don't.
(list (format "(in-ns '%s)
(do (require '[clojure.core :as c]
'[clojure.repl :as r])
(println \"Required namespaces loaded.\"))
" ns))
(list)))) ;; return an empty string if no namespace is found