summaryrefslogtreecommitdiff
path: root/nrepl-client.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2016-02-02 19:26:11 +0200
committerBozhidar Batsov <bozhidar@batsov.com>2016-02-02 19:26:11 +0200
commit742905b407cea046b78b896126781ee1862f4536 (patch)
treef019e7ffbd5f50b4e8d9d842ff1aa6df70639486 /nrepl-client.el
parent5684cff36f9087b1d3d635fe5c2b06d66be5712c (diff)
Improve the names of the nREPL message buffers
Basically, instead of inserting the name of the matching connection verbatim, now we extract just the connection's identifier (which is usually a combination of host, project and port) and use it in the messages buffer's name.
Diffstat (limited to 'nrepl-client.el')
-rw-r--r--nrepl-client.el16
1 files changed, 12 insertions, 4 deletions
diff --git a/nrepl-client.el b/nrepl-client.el
index dbc6f65b..2c139cba 100644
--- a/nrepl-client.el
+++ b/nrepl-client.el
@@ -230,6 +230,10 @@ PROJECT-DIR, HOST and PORT are as in `/nrepl-make-buffer-name'."
(nrepl-make-buffer-name nrepl-connection-buffer-name-template
project-dir host port)))
+(defun nrepl-connection-identifier (conn)
+ "Return the string which identifies a connection CONN."
+ (string-remove-prefix "*cider-repl " (string-remove-suffix "*" (buffer-name conn))))
+
(defun nrepl-server-buffer-name (&optional project-dir host port)
"Return the name of the server buffer.
PROJECT-DIR, HOST and PORT are as in `nrepl-make-buffer-name'."
@@ -1202,7 +1206,7 @@ TYPE is either request or response.
The message is logged to a buffer described by
`nrepl-message-buffer-name-template'."
(when nrepl-log-messages
- (with-current-buffer (nrepl-messages-buffer (current-buffer) msg)
+ (with-current-buffer (nrepl-messages-buffer (current-buffer))
(setq buffer-read-only nil)
(when (> (buffer-size) nrepl-message-buffer-max-size)
(goto-char (/ (buffer-size) nrepl-message-buffer-reduce-denominator))
@@ -1275,10 +1279,14 @@ Set this to nil to prevent truncation."
'follow-link t))))
(insert (color ")\n"))))))))
-(defun nrepl-messages-buffer (conn msg)
- "Return or create the buffer for CONN and MSG.
+(defun nrepl-messages-buffer-name (conn)
+ "Return the name for the message buffer matching CONN."
+ (format nrepl-message-buffer-name-template (nrepl-connection-identifier conn)))
+
+(defun nrepl-messages-buffer (conn)
+ "Return or create the buffer for CONN.
The default buffer name is *nrepl-messages connection*."
- (let ((msg-buffer-name (format nrepl-message-buffer-name-template conn)))
+ (let ((msg-buffer-name (nrepl-messages-buffer-name conn)))
(or (get-buffer msg-buffer-name)
(let ((buffer (get-buffer-create msg-buffer-name)))
(with-current-buffer buffer