Skip to content

Commit 63e6e68

Browse files
committed
Display the current connection in cider-mode's modeline
1 parent c03a988 commit 63e6e68

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
### Changes
5555

56+
* Display the current connection instead of the current namespace in `cider-mode`'s modeline.
5657
* [#1078](https://github.com/clojure-emacs/cider/issues/1078): Removed
5758
`cider-load-fn-into-repl-buffer`, previously bound to `C-c M-f` in the REPL.
5859
* [#1019](https://github.com/clojure-emacs/cider/pull/1019):

cider-mode.el

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,30 @@
3333
(require 'cider-interaction)
3434
(require 'cider-eldoc)
3535

36+
(defun cider--modeline-info ()
37+
"Return info for the `cider-mode' modeline.
38+
39+
Info contains project name and host:port endpoint."
40+
(let ((current-connection (nrepl-current-connection-buffer t)))
41+
(if current-connection
42+
(with-current-buffer current-connection
43+
(format "%s@%s:%s"
44+
(or (nrepl--project-name nrepl-project-dir) "<no project>")
45+
(car nrepl-endpoint)
46+
(cadr nrepl-endpoint)))
47+
"not connected")))
48+
3649
;;;###autoload
3750
(defcustom cider-mode-line
38-
'(:eval (format " cider[%s]" (cider-current-ns)))
51+
'(:eval (format " cider[%s]" (cider--modeline-info)))
3952
"Mode line lighter for `cider-mode'.
4053
4154
The value of this variable is a mode line template as in
4255
`mode-line-format'. See Info Node `(elisp)Mode Line Format' for
4356
details about mode line templates.
4457
4558
Customize this variable to change how `cider-mode' displays its
46-
status in the mode line. The default value displays the current ns.
59+
status in the mode line. The default value displays the current connection.
4760
Set this variable to nil to disable the mode line
4861
entirely."
4962
:group 'cider

0 commit comments

Comments
 (0)