summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2018-11-09 10:08:54 +0100
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-11-10 15:11:22 +0100
commit906295826d0619146d41e1582b9b3f0b96d3b68c (patch)
treea1da62a5796667faf5e789dd03c1b6376780c87b
parent43b6834064351b5e7597ea8e76b35682bd228637 (diff)
Improve friendly session detection
- recognize avfs paths - recognize files in the root of project
-rw-r--r--cider-connection.el21
1 files changed, 16 insertions, 5 deletions
diff --git a/cider-connection.el b/cider-connection.el
index 34ab1f22..bfaa8f76 100644
--- a/cider-connection.el
+++ b/cider-connection.el
@@ -421,16 +421,27 @@ REPL defaults to the current REPL."
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
(when-let* ((repl (cadr session))
(proc (get-buffer-process repl))
- (file (file-truename (or (buffer-file-name)
- default-directory))))
+ (file (file-truename (or (buffer-file-name) default-directory))))
+ ;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
+ (when (string-match-p "#uzip" file)
+ (let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/")))))
+ (setq file (replace-regexp-in-string avfs-path "" file t t))))
(when (process-live-p proc)
(let* ((classpath (or (process-get proc :cached-classpath)
(let ((cp (with-current-buffer repl
(cider-sync-request:classpath))))
(process-put proc :cached-classpath cp)
- cp))))
- (seq-find (lambda (path) (string-prefix-p path file))
- classpath)))))
+ cp)))
+ (classpath-roots (or (process-get proc :cached-classpath-roots)
+ (let ((cp (thread-last classpath
+ (seq-filter (lambda (path) (not (string-match-p "\\.jar$" path))))
+ (mapcar #'file-name-directory))))
+ (process-put proc :cached-classpath-roots cp)
+ cp))))
+ (or (seq-find (lambda (path) (string-prefix-p path file))
+ classpath)
+ (seq-find (lambda (path) (string-prefix-p path file))
+ classpath-roots))))))
(defvar cider-sesman-browser-map
(let ((map (make-sparse-keymap)))