Skip to content

Commit

Permalink
Improve readability and visibility of *nrepl-messages* buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Sep 12, 2014
1 parent 5763280 commit 83dbab8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions nrepl-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ Return new dict. Dict is modified by side effects."
collect (car l))
(error "Not a nREPL dict.")))


(defun nrepl--cons (car list-or-dict)
"Generic cons of CAR to LIST-OR-DICT."
(if (eq (car list-or-dict) 'dict)
Expand Down Expand Up @@ -474,7 +473,7 @@ First we check the callbacks of pending requests. If no callback was found,
we check the completed requests, since responses could be received even for
older requests with \"done\" status."
(nrepl-dbind-response response (id)
(nrepl-log-message response)
(nrepl-log-message (cons '<- (cdr response)))
(let ((callback (or (gethash id nrepl-pending-requests)
(gethash id nrepl-completed-requests))))
(if callback
Expand Down Expand Up @@ -698,7 +697,7 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
(let* ((request-id (nrepl-next-request-id))
(request (append (list 'dict "id" request-id) request))
(message (nrepl-bencode request)))
(nrepl-log-message request)
(nrepl-log-message (cons '---> (cdr request)))
(with-current-buffer (nrepl-current-connection-buffer)
(puthash request-id callback nrepl-pending-requests)
(process-send-string nil message))))
Expand Down Expand Up @@ -948,14 +947,17 @@ number of buffer shrinking operations.")
(re-search-forward "^(" nil t)
(delete-region (point-min) (- (point) 1)))
(goto-char (point-max))
(nrepl--pp msg (current-buffer)))))
(nrepl--pp msg (current-buffer))
(-when-let (win (get-buffer-window))
(set-window-point win (point-max))))))

(defun nrepl--pp (object &optional stream)
"Pretty print nREPL objects."
(let ((stream (or stream standard-output)))
(if (not (nrepl-dict-p object))
(if (not (and (listp object)
(memq (car object) '(<- --->))))
(pp object stream)
(princ "(dict\n" stream)
(princ (format "(%s\n" (car object)) stream)
(cl-loop for l on (cdr object) by #'cddr
do (princ (format " %s\t%s%s"
(car l) (pp-to-string (cadr l))
Expand Down

0 comments on commit 83dbab8

Please sign in to comment.