Fork me on GitHub
#cider
<
2024-01-28
>
hifumi12305:01:39

The error message when running C-c C-k is a bit confusing. The name in the menu bar states “Load this buffer”, but if you use cider-scratch buffer, an error occurs because the scratch buffer is not associated with a file. Does that mean C-c C-k is restricted to files? If so, would it be possible to rename the menu item to e.g. “Load this file”

vemv09:01:22

I think I know what it is However please state the problem in a clearer way, e.g. refer the function by name (a few of us don't use C-), copy the exact error message you see, etc

hifumi12309:01:11

cider-load-buffer is the function and the error message is

cider-load-buffer: Buffer '*cider-scratch*' is not associated with a file

👍 1
vemv09:01:31

Ok, at first I thought it was a sesman issue, but that's not it this helper essentially calls the nrepl "load-file" op. Its doc is:

:doc "Loads a body of code, using supplied path and filename info to set source file and line number metadata. Delegates to underlying \"eval\" middleware/handler."
:requires {"file" "Full contents of a file of code."}
:optional (merge caught/wrap-caught-optional-arguments
                 print/wrap-print-optional-arguments
                 {"file-path" "Source-path-relative path of the source file, e.g. clojure/java/io.clj"
                  "file-name" "Name of source file, e.g. io.clj"})
So, the filename is indeed optional, and cider.el probably was too rigid there

vemv09:01:28

I'd suggest, jump to cider-load-buffer and play with it, you essentially want to:

(cider-request:load-file (buffer-string) blah blah)
If it works, feel free to report back :) I may play with this (especially if an issue gets created) although it doesn't seem very prioritary

vemv09:01:06

(bear in mind that if you load code this way, stacktraces, jump-to-def, etc will be less functional)