summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2018-08-15 00:39:25 +0200
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-08-16 23:02:37 +0200
commitf2ab3d36a8b535c111d78a75cda600f11860a9e9 (patch)
tree0b07df8f8a6e6b60ab034ab2443f4067e94abbea
parentad932aca160785eae2fbc0d6028a730d12ff193c (diff)
[Fix #2415] Filter out killed buffers in `cider-repls`
If a REPL buffer is killed manually it will leak out of `cider-repls` for .cljc files, so make sure `cider-repls` only return live REPL buffers.
-rw-r--r--cider-connection.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/cider-connection.el b/cider-connection.el
index 08b102f3..46029d8e 100644
--- a/cider-connection.el
+++ b/cider-connection.el
@@ -662,6 +662,13 @@ session."
type (car (sesman-current-session 'CIDER)))
repl))))
+(defun cider--match-repl-type (type buffer)
+ "Return non-nil if TYPE matches BUFFER's REPL type."
+ (let ((buffer-repl-type (cider-repl-type buffer)))
+ (cond ((null buffer-repl-type) nil)
+ ((or (null type) (equal type "multi")) t)
+ (t (string= type buffer-repl-type)))))
+
(defun cider-repls (&optional type ensure)
"Return cider REPLs of TYPE from the current session.
If TYPE is nil or \"multi\", return all repls. If ENSURE is non-nil, throw
@@ -669,11 +676,8 @@ an error if no linked session exists."
(let ((repls (cdr (if ensure
(sesman-ensure-session 'CIDER)
(sesman-current-session 'CIDER)))))
- (if (or (null type) (equal type "multi"))
- repls
- (seq-filter (lambda (b)
- (string= type (cider-repl-type b)))
- repls))))
+ (seq-filter (lambda (b)
+ (cider--match-repl-type type b)) repls)))
(defun cider-map-repls (which function)
"Call FUNCTION once for each appropriate REPL as indicated by WHICH.