summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2016-10-10 15:28:21 +0200
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2016-10-10 18:11:51 +0300
commite4ab03e34696aa957dac91d67af5f3d82a750b7c (patch)
tree9c149b07d5f2166a0759decc7aa8a7d1be2480be
parentf28ebb7156ea382b7e53452fbb27c80143fc03f6 (diff)
Explicitly list unfolding parameters in nrepl--pp
-rw-r--r--CHANGELOG.md2
-rw-r--r--nrepl-client.el51
2 files changed, 27 insertions, 26 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e4891c4..92a6ad2a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,7 +26,7 @@ within the scope of your current Emacs session.
* Add option to define exclusions for injected dependecies. Fixes [#1824](https://github.com/clojure-emacs/cider/issues/1824): Can no longer jack-in to an inherited clojure version.
* [#1820](https://github.com/clojure-emacs/cider/issues/1820): Don't try to display eldoc in EDN buffers.
* [#1823](https://github.com/clojure-emacs/cider/issues/1823): Fix column location metadata set by interactive evaluation.
-* [#1859](https://github.com/clojure-emacs/cider/issues/1859): Remove the overhead of nREPL message log.
+* [#1859](https://github.com/clojure-emacs/cider/issues/1859): Make nREPL message log much faster. `nrepl-dict-max-message-size` custom variable was removed.
## 0.13.0 (2016-07-25)
diff --git a/nrepl-client.el b/nrepl-client.el
index 3c383a4d..0cb5dcd0 100644
--- a/nrepl-client.el
+++ b/nrepl-client.el
@@ -1128,11 +1128,6 @@ If ID is nil, return nil."
(mod (length nrepl-message-colors))
(nth nrepl-message-colors))))
-(defcustom nrepl-dict-max-message-size 5
- "Max number of lines a dict can have before being truncated.
-Set this to nil to prevent truncation."
- :type 'integer)
-
(defun nrepl--expand-button (button)
"Expand the text hidden under overlay BUTTON."
(let* ((start (overlay-start button))
@@ -1196,26 +1191,32 @@ FOREGROUND and BUTTON are as in `nrepl--pp'."
"Pretty print nREPL OBJECT, delimited using FOREGROUND.
If BUTTON is non-nil, try making a button from OBJECT instead of inserting
it into the buffer."
- (if-let ((head (car-safe object)))
- ;; listlike objects
- (cond
- ((memq head '(<-- -->))
- (nrepl--pp-listlike object foreground button))
- ((eq head 'dict)
- (if (and button (> (length object) 1))
- (nrepl--insert-button "(dict ...)" object)
- (nrepl--pp-listlike object foreground button)))
- (t
- (if (and button (> (length object) 10))
- (nrepl--insert-button (format "(%s ...)" (prin1-to-string head)) object)
- (pp object (current-buffer)))))
- ;; non-list objects
- (if (stringp object)
- (if (and button (> (length object) 80))
- (nrepl--insert-button (format "\"%s...\"" (substring object 0 40)) object)
- (insert (prin1-to-string object) "\n"))
- (pp object (current-buffer))
- (insert "\n"))))
+ (let ((min-dict-fold-size 1)
+ (min-list-fold-size 10)
+ (min-string-fold-size 60))
+ (if-let ((head (car-safe object)))
+ ;; list-like objects
+ (cond
+ ;; top level dicts (always unfolded)
+ ((memq head '(<-- -->))
+ (nrepl--pp-listlike object foreground button))
+ ;; inner dicts
+ ((eq head 'dict)
+ (if (and button (> (length object) min-dict-fold-size))
+ (nrepl--insert-button "(dict ...)" object)
+ (nrepl--pp-listlike object foreground button)))
+ ;; lists
+ (t
+ (if (and button (> (length object) min-list-fold-size))
+ (nrepl--insert-button (format "(%s ...)" (prin1-to-string head)) object)
+ (pp object (current-buffer)))))
+ ;; non-list objects
+ (if (stringp object)
+ (if (and button (> (length object) min-string-fold-size))
+ (nrepl--insert-button (format "\"%s...\"" (substring object 0 min-string-fold-size)) object)
+ (insert (prin1-to-string object) "\n"))
+ (pp object (current-buffer))
+ (insert "\n")))))
(defun nrepl-messages-buffer-name (conn)
"Return the name for the message buffer matching CONN."