33
33
(require 'cl-lib )
34
34
(require 'format-spec )
35
35
(require 'sesman )
36
+ (require 'sesman-browser )
36
37
37
38
(defcustom cider-session-name-template " %J:%h:%p"
38
39
" Format string to use for session names.
@@ -318,28 +319,36 @@ about this buffer (like variable `cider-repl-type')."
318
319
319
320
; ;; Cider's Connection Management UI
320
321
321
- (defun cider-quit ()
322
- " Quit the currently active CIDER connection."
322
+ (defun cider-quit (&optional repl )
323
+ " Quit the CIDER connection associated with REPL.
324
+ REPL defaults to the current REPL."
323
325
(interactive )
324
- (cider-ensure-connected)
325
- (let ((connection (cider-current-repl)))
326
- (cider--close-connection connection))
326
+ (let ((repl (or repl
327
+ (sesman-browser-get 'object )
328
+ (cider-current-repl nil 'ensure ))))
329
+ (cider--close-connection repl))
327
330
; ; if there are no more connections we can kill all ancillary buffers
328
331
(unless (cider-connected-p)
329
- (cider-close-ancillary-buffers)))
330
-
331
- (defun cider-restart ()
332
- " Restart the currently active CIDER connection.
333
- Don't restart the server or other connections within the same session. Use
334
- `sesman-restart' to restart the entire session."
332
+ (cider-close-ancillary-buffers))
333
+ ; ; need this to refresh sesman browser
334
+ (run-hooks 'sesman-post-command-hook ))
335
+
336
+ (defun cider-restart (&optional repl )
337
+ " Restart CIDER connection associated with REPL.
338
+ REPL defaults to the current REPL. Don't restart the server or other
339
+ connections within the same session. Use `sesman-restart' to restart the
340
+ entire session."
335
341
(interactive )
336
- (let* ((repl (or (cider-current-repl)
337
- (user-error " No linked REPL" )))
342
+ (let* ((repl (or repl
343
+ (sesman-browser-get 'object )
344
+ (cider-current-repl nil 'ensure )))
338
345
(params (thread-first (cider--gather-connect-params nil repl)
339
346
(plist-put :session-name (sesman-session-name-for-object 'CIDER repl))
340
347
(plist-put :repl-buffer repl))))
341
348
(cider--close-connection repl 'no-kill )
342
- (cider-nrepl-connect params)))
349
+ (cider-nrepl-connect params)
350
+ ; ; need this to refresh sesman browser
351
+ (run-hooks 'sesman-post-command-hook )))
343
352
344
353
(defun cider-close-ancillary-buffers ()
345
354
" Close buffers that are shared across connections."
@@ -348,11 +357,15 @@ Don't restart the server or other connections within the same session. Use
348
357
(when (get-buffer buf-name)
349
358
(kill-buffer buf-name))))
350
359
351
- (defun cider-describe-current-connection ()
352
- " Display information about the current connection."
360
+ (defun cider-describe-connection (&optional repl )
361
+ " Display information about the connection associated with REPL.
362
+ REPL defaults to the current REPL."
353
363
(interactive )
354
- (message " %s " (cider--connection-info (cider-current-repl nil 'ensure ))))
355
- (define-obsolete-function-alias 'cider-display-connection-info 'cider-describe-current-connection " 0.18.0" )
364
+ (let ((repl (or repl
365
+ (sesman-browser-get 'object )
366
+ (cider-current-repl nil 'ensure ))))
367
+ (message " %s " (cider--connection-info repl))))
368
+ (define-obsolete-function-alias 'cider-display-connection-info 'cider-describe-connection " 0.18.0" )
356
369
357
370
(defconst cider-nrepl-session-buffer " *cider-nrepl-session*" )
358
371
@@ -387,13 +400,27 @@ Don't restart the server or other connections within the same session. Use
387
400
(cl-defmethod sesman-more-relevant-p ((_system (eql CIDER)) session1 session2)
388
401
(sesman-more-recent-p (cdr session1) (cdr session2)))
389
402
403
+ (defvar cider-sesman-browser-map
404
+ (let ((map (make-sparse-keymap )))
405
+ (define-key map (kbd " j q" ) #'cider-quit )
406
+ (define-key map (kbd " j k" ) #'cider-quit )
407
+ (define-key map (kbd " j r" ) #'cider-restart )
408
+ (define-key map (kbd " j d" ) #'cider-describe-connection )
409
+ (define-key map (kbd " j i" ) #'cider-describe-connection )
410
+ (define-key map (kbd " C-c C-q" ) #'cider-quit )
411
+ (define-key map (kbd " C-c C-q" ) #'cider-quit )
412
+ (define-key map (kbd " C-c C-r" ) #'cider-restart )
413
+ (define-key map (kbd " C-c M-r" ) #'cider-restart )
414
+ (define-key map (kbd " C-c C-d" ) #'cider-describe-connection )
415
+ (define-key map (kbd " C-c M-d" ) #'cider-describe-connection )
416
+ (define-key map (kbd " C-c C-i" ) #'cider-describe-connection )
417
+ map)
418
+ " Map active on REPL objects in sesman browser." )
419
+
390
420
(cl-defmethod sesman-session-info ((_system (eql CIDER)) session)
391
421
(interactive " P" )
392
- (let ((repl (cadr session)))
393
- (format " \t %s : %s \n\t REPLS: %s "
394
- (if (buffer-local-value 'nrepl-server-buffer repl) " SERVER" " CONNECTION" )
395
- (cider--connection-info repl t )
396
- (mapconcat #'buffer-name (cdr session) " , " ))))
422
+ (list :objects (cdr session)
423
+ :map cider-sesman-browser-map))
397
424
398
425
(declare-function cider " cider" )
399
426
(cl-defmethod sesman-start-session ((_system (eql CIDER)))
@@ -486,7 +513,9 @@ removed."
486
513
" "
487
514
host))
488
515
(repl-type (or (plist-get params :repl-type ) " unknown" ))
489
- (cljs-repl-type (or (plist-get params :cljs-repl-type ) " " ))
516
+ (cljs-repl-type (or (and (equal repl-type " cljs" )
517
+ (plist-get params :cljs-repl-type ))
518
+ " " ))
490
519
(specs `((?h . , host )
491
520
(?H . , remote-host )
492
521
(?p . , port )
0 commit comments