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 /helpful.el | |
| 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).
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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 |
