Skip to content

Commit

Permalink
Improve mode-line lighter
Browse files Browse the repository at this point in the history
  • Loading branch information
Malabarba committed Jul 13, 2015
1 parent 36e6b0a commit 8d79f8f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cider-interaction.el
Expand Up @@ -312,7 +312,10 @@ Signal an error if it is not supported."
Info contains project name, current REPL namespace, host:port
endpoint and Clojure version."
(with-current-buffer (get-buffer connection-buffer)
(format "Active nREPL connection: %s@%s:%s (Java %s, Clojure %s, nREPL %s)"
(format "Active nREPL connection: %s%s@%s:%s (Java %s, Clojure %s, nREPL %s)"
(if nrepl-sibling-buffer-alist
(upcase (concat cider-repl-type " "))
"")
(or (nrepl--project-name nrepl-project-dir) "<no project>")
(car nrepl-endpoint)
(cadr nrepl-endpoint)
Expand Down
22 changes: 17 additions & 5 deletions cider-mode.el
Expand Up @@ -33,17 +33,29 @@
(require 'cider-interaction)
(require 'cider-eldoc)

(defcustom cider-mode-line-show-connection t
"If the mode-line lighter should detail the connection."
:group 'cider
:type 'boolean
:package-version '(cider "0.10.0"))

(defun cider--modeline-info ()
"Return info for the `cider-mode' modeline.
Info contains project name and host:port endpoint."
(let ((current-connection (nrepl-current-connection-buffer t)))
(let ((current-connection (cider-current-repl-buffer)))
(if current-connection
(with-current-buffer current-connection
(format "%s@%s:%s"
(or (nrepl--project-name nrepl-project-dir) "<no project>")
(car nrepl-endpoint)
(cadr nrepl-endpoint)))
(concat
(when nrepl-sibling-buffer-alist
(concat cider-repl-type ":"))
(when cider-mode-line-show-connection
(format "%s@%s:%s"
(or (nrepl--project-name nrepl-project-dir) "<no project>")
(pcase (car nrepl-endpoint)
("localhost" "")
(x x))
(cadr nrepl-endpoint)))))
"not connected")))

;;;###autoload
Expand Down
8 changes: 6 additions & 2 deletions nrepl-client.el
Expand Up @@ -1421,13 +1421,17 @@ The connections buffer is determined by
(buffer (get-buffer connection))
(endpoint (buffer-local-value 'nrepl-endpoint buffer)))
(insert
(format "%s %-16s %5s %s"
(format "%s %-16s %5s %s%s"
(if (equal connection (car nrepl-connection-list)) "*" " ")
(car endpoint)
(prin1-to-string (cadr endpoint))
(or (nrepl--project-name
(buffer-local-value 'nrepl-project-dir buffer))
"")))))
"")
(with-current-buffer buffer
(if nrepl-sibling-buffer-alist
(concat " " cider-repl-type)
""))))))

(defun nrepl--project-name (stack)
"Extracts a project name from STACK, possibly nil.
Expand Down

0 comments on commit 8d79f8f

Please sign in to comment.