diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-03-31 19:40:30 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-03-31 19:40:30 +0100 |
| commit | c527d0a9f66b50c28dfc44b88c5dd634c770ade2 (patch) | |
| tree | 79fd0b40816b61a9943871e1ce0bd89291cd7405 | |
| parent | 5681a5df8e157d0dae9c99df5455755353a68c8b (diff) | |
Use the default Emacs pretty-printer0.9
This is generally more robust, faster, with more attractive results.
Also gracefully handle the user quitting during
pretty-printing (common for large lists like load-history).
| -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 |
