@@ -649,11 +649,15 @@ existing file ending with URL has been found."
649649 (t (-if-let (path (cider--file-path url))
650650 (find-file-noselect path)
651651 (unless (file-name-absolute-p url)
652- (cl-loop for bf in (cider-util--clojure-buffers)
653- for path = (with-current-buffer bf
654- (expand-file-name url))
655- if (and path (file-exists-p path))
656- return (find-file-noselect path)))))))
652+ (let ((cider-buffers (cider-util--clojure-buffers)))
653+ (or (cl-loop for bf in cider-buffers
654+ for path = (with-current-buffer bf
655+ (expand-file-name url))
656+ if (and path (file-exists-p path))
657+ return (find-file-noselect path))
658+ (cl-loop for bf in cider-buffers
659+ if (string= (buffer-name bf) url)
660+ return bf))))))))
657661
658662(defun cider-find-var-file (var )
659663 " Return the buffer visiting the file in which VAR is defined, or nil if
@@ -1235,7 +1239,8 @@ function is the main entry point in CIDER's interactive evaluation API. All
12351239other interactive eval functions should rely on this function. If CALLBACK
12361240is nil use `cider-interactive-eval-handler' ."
12371241 (cider--clear-compilation-highlights)
1238- (let ((filename (buffer-file-name )))
1242+ (let ((filename (or (buffer-file-name )
1243+ (buffer-name ))))
12391244 (cider-request:load-file
12401245 (cider--dummy-file-contents form start-pos)
12411246 (funcall cider-to-nrepl-filename-function (cider--server-filename filename))
@@ -1247,14 +1252,18 @@ is nil use `cider-interactive-eval-handler'."
12471252START-POS is a starting position of the form in the original context."
12481253 (let* ((ns-form (if (cider-ns-form-p form)
12491254 " "
1250- (cider-ns-form)))
1255+ (or (cider-ns-form)
1256+ (->> (get-buffer (cider-current-repl-buffer))
1257+ (buffer-local-value 'nrepl-buffer-ns )
1258+ (setq nrepl-buffer-ns)
1259+ (format " (ns %s ) " )))))
12511260 (ns-form-lines (length (split-string ns-form " \n " )))
12521261 (start-pos (or start-pos 1 ))
12531262 (start-line (line-number-at-pos start-pos))
12541263 (start-column (save-excursion (goto-char start-pos) (current-column ))))
12551264 (concat
12561265 ns-form
1257- (make-string (- start-line ns-form-lines) ?\n )
1266+ (make-string (max 0 ( - start-line ns-form-lines) ) ?\n )
12581267 (make-string start-column ? )
12591268 form)))
12601269
0 commit comments