diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | helpful.el | 15 |
2 files changed, 12 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b76a24..0190e25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ being linkified. Fixed an issue where the definition of interactively defined functions wasn't shown. +Pretty-printing is now much more robust, gracefully handling very +large lists. + # v0.8 Added setting `helpful-switch-buffer-function` to allow users to @@ -152,12 +152,15 @@ To disable cleanup entirely, set this variable to nil. See also (defun helpful--pretty-print (value) "Pretty-print VALUE. -Break lists over large lines, and ensure strings are surrounded -with double-quotes." - (with-temp-buffer - (delay-mode-hooks (lisp-mode)) - (cl-prettyprint value) - (s-trim (buffer-string)))) + +If VALUE is self-referential, or just very big, the user may +press \\[keyboard-quit] to gracefully stop the printing." + ;; Inspired by `ielm-eval-input'. + (condition-case nil + (s-trim-right (pp-to-string value)) + (quit + (propertize "(User quit during pretty-printing.)" + 'face 'font-lock-comment-face)))) (defun helpful--button (text type &rest properties) ;; `make-text-button' mutates our string to add properties. Copy |
