Fork me on GitHub

I have a problem with the clojure.repl/source function in CIDER. Consider:

(ns omicron.core
  (:require [clojure.repl :as repl]))

(defn foo [a] (inc a))

(repl/source omicron.core/foo)
When I eval this buffer in CIDER, it will print in the repl Source not found , while if I require the file via clj it will print the source. What could the problem be?


when you eval code interactively, especially via a repl, the source is the repl, so it makes sense for the source not to be found What specific cider ops are you using to load code? Those that are related to files should preserve source info, and those that are more 'free form', not so much


I am using both cider-eval-buffer and cider-eval-defun-at-point . What should I be using instead?


Same with cider-eval-file

👍 1

cider-refresh is one that would almost certainly work, however if that's not your jam, I wouldn't want to suggest a change of workflow probably cider-eval-buffer/`cider-eval-defun-at-point` might be fixable although I'd imagine we cannot always guarantee that the file will be associated. cider-eval-file surprises me more, and it could make a stronger guarantee Could you create a (single) issue for this? Perhaps it's never been implemented to begin with, IDK


One has to bind *file* as one loads code, perhaps cider forgot to do that


Also, one additional question, does jump-to-source work in these cases?


Indeed, cider-ns-refresh does the right thing. Yes, jump-to-source works (but I'm not sure which function is used to get that in doom emacs+lsp, so maybe that's not CIDER's merit)


I find this behavior counterintuitive because:

> (meta #'omicron.core/foo)

{:arglists ([a]),
 :line 40,
 :column 1,
 :file "/home/carlo/code/clojure/omicron/src/omicron/core.clj",
 :name foo,
 :ns #namespace[omicron.core]}
so at some point we know that the var belongs to the file (and where)


my point being that I would like cider-eval-defun-at-point to try to associate the right informations, at least


opening an issue

🙌 1


💯 1

I verified and described what has to be done. I might give it a shot, however I don't have much time in my hands (and other priorities for cider dev!) so this would be both a pretty easy task and a very appreciated one. Up to you :)


Thank you @U45T93RA6, much appreciated 🙌