@@ -588,9 +588,9 @@ If no local or remote file exists, return nil."
588
588
(cond ((equal local-path " " ) " " )
589
589
((and cider-prefer-local-resources (file-exists-p local-path))
590
590
local-path)
591
- ((file-exists-p tramp-path)
591
+ ((and tramp-path ( file-exists-p tramp-path) )
592
592
tramp-path)
593
- ((file-exists-p local-path)
593
+ ((and local-path ( file-exists-p local-path) )
594
594
local-path))))
595
595
596
596
(defun cider--url-to-file (url )
@@ -604,10 +604,19 @@ create a valid path."
604
604
(match-string 1 filename)
605
605
filename)))
606
606
607
+ (defun cider--tooling-file-p (file-name )
608
+ " Return t if FILE-NAME is not a 'real' source file.
609
+ Currently, only check if the relative file name starts with 'form-init'
610
+ which nREPL uses for temporary evaluation file names."
611
+ (string-match-p " \\ bform-init" (file-name-nondirectory file-name)))
612
+
607
613
(defun cider-find-file (url )
608
614
" Return a buffer visiting the file URL if it exists, or nil otherwise.
609
- The argument should have a scheme prefix, and represent a fully-qualified file
610
- path or an entry within a zip/jar archive."
615
+ If URL has a scheme prefix, it must represent a fully-qualified file path
616
+ or an entry within a zip/jar archive. If URL doesn't contain a scheme
617
+ prefix and is an absolute path, it is treated as such. Finally, if URL is
618
+ relative, it is expanded within each of the open Clojure buffers till an
619
+ existing file ending with URL has been found."
611
620
(cond ((string-match " ^file:\\ (.+\\ )" url)
612
621
(-when-let* ((file (cider--url-to-file (match-string 1 url)))
613
622
(path (cider--file-path file)))
@@ -639,7 +648,15 @@ path or an entry within a zip/jar archive."
639
648
(setq-local buffer-read-only t )
640
649
(set-buffer-modified-p nil )
641
650
(set-auto-mode )
642
- (current-buffer ))))))))
651
+ (current-buffer ))))))
652
+ (t (-if-let (path (cider--file-path url))
653
+ (find-file-noselect path)
654
+ (unless (file-name-absolute-p url)
655
+ (cl-loop for bf in (cider-util--clojure-buffers)
656
+ for path = (with-current-buffer bf
657
+ (expand-file-name url))
658
+ if (and path (file-exists-p path))
659
+ return (find-file-noselect path)))))))
643
660
644
661
(defun cider-find-var-file (var )
645
662
" Return the buffer visiting the file in which VAR is defined, or nil if
@@ -686,9 +703,10 @@ When called interactively, this operates on point."
686
703
" Jump to location give by INFO.
687
704
INFO object is returned by `cider-var-info' or `cider-member-info' .
688
705
OTHER-BUFFER is passed to `cider-jamp-to' ."
689
- (-if-let* ((file (cadr (assoc " file" info)))
690
- (line (cadr (assoc " line" info)))
691
- (buffer (cider-find-file file)))
706
+ (-if-let* ((line (cadr (assoc " line" info)))
707
+ (file (cadr (assoc " file" info)))
708
+ (buffer (unless (cider--tooling-file-p file)
709
+ (cider-find-file file))))
692
710
(cider-jump-to buffer (cons line nil ) other-buffer)
693
711
; ; var was created interactively and has no file info
694
712
(-if-let* ((ns (cadr (assoc " ns" info)))
@@ -1092,7 +1110,7 @@ until we find a delimiters that's not inside a string."
1092
1110
(backward-char )))
1093
1111
1094
1112
(defun cider--find-last-error-location (buffer message )
1095
- " Return the location (begin . end) in BUFFER from the clojure error MESSAGE.
1113
+ " Return the location (begin . end) in BUFFER from the Clojure error MESSAGE.
1096
1114
If location could not be found, return nil."
1097
1115
(save-excursion
1098
1116
(with-current-buffer buffer
0 commit comments