@@ -273,7 +273,6 @@ Return new dict. Dict is modified by side effects."
273
273
collect (car l))
274
274
(error " Not a nREPL dict. " )))
275
275
276
-
277
276
(defun nrepl--cons (car list-or-dict )
278
277
" Generic cons of CAR to LIST-OR-DICT."
279
278
(if (eq (car list-or-dict) 'dict )
@@ -474,7 +473,7 @@ First we check the callbacks of pending requests. If no callback was found,
474
473
we check the completed requests, since responses could be received even for
475
474
older requests with \" done\" status."
476
475
(nrepl-dbind-response response (id)
477
- (nrepl-log-message response)
476
+ (nrepl-log-message ( cons '<- ( cdr response)) )
478
477
(let ((callback (or (gethash id nrepl-pending-requests)
479
478
(gethash id nrepl-completed-requests))))
480
479
(if callback
@@ -698,7 +697,7 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
698
697
(let* ((request-id (nrepl-next-request-id))
699
698
(request (append (list 'dict " id" request-id) request))
700
699
(message (nrepl-bencode request)))
701
- (nrepl-log-message request)
700
+ (nrepl-log-message ( cons '--- > ( cdr request)) )
702
701
(with-current-buffer (nrepl-current-connection-buffer)
703
702
(puthash request-id callback nrepl-pending-requests)
704
703
(process-send-string nil message))))
@@ -948,21 +947,37 @@ number of buffer shrinking operations.")
948
947
(re-search-forward " ^(" nil t )
949
948
(delete-region (point-min ) (- (point ) 1 )))
950
949
(goto-char (point-max ))
951
- (nrepl--pp msg (current-buffer )))))
952
-
953
- (defun nrepl--pp (object &optional stream )
954
- " Pretty print nREPL objects."
955
- (let ((stream (or stream standard-output)))
956
- (if (not (nrepl-dict-p object))
957
- (pp object stream)
958
- (princ " (dict\n " stream)
959
- (cl-loop for l on (cdr object) by #'cddr
960
- do (princ (format " %s \t %s%s "
961
- (car l) (pp-to-string (cadr l))
962
- (if (cddr l) " \n " " " ))
963
- stream))
964
- (princ " )\n " stream))
965
- (if (stringp object) (princ " \n " stream))))
950
+ (nrepl--pp msg)
951
+ (-when-let (win (get-buffer-window ))
952
+ (set-window-point win (point-max ))))))
953
+
954
+ (defvar nrepl--message-colors
955
+ '(" red" " brown" " coral" " orange" " green" " deep sky blue" " blue" " dark violet" )
956
+ " Colors used in `nrepl-messages-buffer' ." )
957
+
958
+ (defun nrepl--pp (object )
959
+ " Pretty print nREPL OBJECT."
960
+ (if (not (and (listp object)
961
+ (memq (car object) '(<- ---> dict))))
962
+ (progn (pp object (current-buffer ))
963
+ (unless (listp object) (insert " \n " )))
964
+ (let* ((id (lax-plist-get (cdr object) " id" ))
965
+ (id (and id (mod (string-to-number id)
966
+ (length nrepl--message-colors))))
967
+ (head (format " (%s " (car object)))
968
+ (foreground (and id (nth id nrepl--message-colors))))
969
+ (cl-flet ((color (str)
970
+ (propertize str 'face `(:weight ultra-bold :foreground , foreground ))))
971
+ (insert (color head))
972
+ (let ((indent (+ 2 (- (current-column ) (length head)))))
973
+ (if (null (cdr object))
974
+ (insert " )\n " )
975
+ (insert " \n " )
976
+ (cl-loop for l on (cdr object) by #'cddr
977
+ do (let ((str (format " %s%s " (make-string indent ? ) (car l))))
978
+ (insert str)
979
+ (nrepl--pp (cadr l))))
980
+ (insert (color (format " %s )\n " (make-string (- indent 2 ) ? ))))))))))
966
981
967
982
(defun nrepl-messages-buffer ()
968
983
" Return or create the buffer given by `nrepl-message-buffer-name' .
0 commit comments