From 8d79f8f0b28193d08d99a85e59a97dbc0b309282 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 11 Jul 2015 19:09:46 +0100 Subject: [PATCH] Improve mode-line lighter --- cider-interaction.el | 5 ++++- cider-mode.el | 22 +++++++++++++++++----- nrepl-client.el | 8 ++++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/cider-interaction.el b/cider-interaction.el index 59752ee87..2b935f30e 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -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) "") (car nrepl-endpoint) (cadr nrepl-endpoint) diff --git a/cider-mode.el b/cider-mode.el index 388d5418c..0a0e3b795 100644 --- a/cider-mode.el +++ b/cider-mode.el @@ -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) "") - (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) "") + (pcase (car nrepl-endpoint) + ("localhost" "") + (x x)) + (cadr nrepl-endpoint))))) "not connected"))) ;;;###autoload diff --git a/nrepl-client.el b/nrepl-client.el index c1430dc54..b7731eaaf 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -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.