summaryrefslogtreecommitdiff
path: root/nrepl-client.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2015-11-29 09:35:36 +0200
committerBozhidar Batsov <bozhidar@batsov.com>2015-11-29 09:35:36 +0200
commit1d7648cdc720beac8344ab916d6d0dbc7ff2ae4c (patch)
tree8530ac7bf1c65825377bc1b6645c9dca6f43be81 /nrepl-client.el
parent817d37e0d9f8f814043e9fdcfc9eb96a8aadc930 (diff)
Dump decoding errors to a dedicated nREPL error buffer
Diffstat (limited to 'nrepl-client.el')
-rw-r--r--nrepl-client.el27
1 files changed, 24 insertions, 3 deletions
diff --git a/nrepl-client.el b/nrepl-client.el
index 13d2d147..e93a3b04 100644
--- a/nrepl-client.el
+++ b/nrepl-client.el
@@ -182,6 +182,7 @@ To be used for tooling calls (i.e. completion, eldoc, etc)")
;;; nREPL Buffer Names
(defconst nrepl-message-buffer-name-template "*nrepl-messages %s*")
+(defconst nrepl-error-buffer-name "*nrepl-error*")
(defconst nrepl-repl-buffer-name-template "*cider-repl%s*")
(defconst nrepl-connection-buffer-name-template "*nrepl-connection%s*")
(defconst nrepl-server-buffer-name-template "*nrepl-server%s*")
@@ -493,11 +494,11 @@ object is a root list or dict."
;; else, throw a quiet error
(t
(message "Invalid bencode message detected. See %s buffer."
- nrepl-message-buffer-name-template)
- (nrepl-log-message
+ nrepl-error-buffer-name)
+ (nrepl-log-error
(format "Decoder error at position %d (`%s'):"
(point) (buffer-substring (point) (min (+ (point) 10) (point-max)))))
- (nrepl-log-message (buffer-string))
+ (nrepl-log-error (buffer-string))
(ding)
;; Ensure loop break and clean queues' states in nrepl-bdecode:
(goto-char (point-max))
@@ -1272,6 +1273,26 @@ The default buffer name is *nrepl-messages session*."
(nrepl-messages-mode)
buffer)))))
+(defun nrepl-error-buffer ()
+ "Return or create the buffer.
+The default buffer name is *nrepl-error*."
+ (or (get-buffer nrepl-error-buffer-name)
+ (let ((buffer (get-buffer-create nrepl-error-buffer-name)))
+ (with-current-buffer buffer
+ (buffer-disable-undo)
+ (fundamental-mode)
+ buffer))))
+
+(defun nrepl-log-error (msg)
+ "Log the given MSG to the buffer given by `nrepl-error-buffer'."
+ (with-current-buffer (nrepl-error-buffer)
+ (setq buffer-read-only nil)
+ (goto-char (point-max))
+ (insert msg)
+ (when-let ((win (get-buffer-window)))
+ (set-window-point win (point-max)))
+ (setq buffer-read-only t)))
+
(defun nrepl-create-client-buffer-default (endpoint)
"Create an nREPL client process buffer.
ENDPOINT is a plist returned by `nrepl-connect'."