From e4ab03e34696aa957dac91d67af5f3d82a750b7c Mon Sep 17 00:00:00 2001 From: Vitalie Spinu Date: Mon, 10 Oct 2016 15:28:21 +0200 Subject: Explicitly list unfolding parameters in nrepl--pp --- CHANGELOG.md | 2 +- nrepl-client.el | 51 ++++++++++++++++++++++++++------------------------- 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." -- cgit v1.2.3