Speed up describe-char
when a property has a large value
Doing `C-u C-x =` on a buffer position where the overlay/text properties hold large values (e.g. inside the profiler report) can be surprisingly slow because it pretty prints all those properties. Change the code to do the pretty printing more lazily. While at it, share that duplicated code between `descr-text.el` and `wid-browse.el`. * lisp/emacs-lisp/pp.el (pp-insert-short-sexp): New function. * lisp/descr-text.el (describe-text-sexp): Delete function. (describe-property-list): Use `pp-insert-short-sexp` instead. * lisp/wid-browse.el (widget-browse-sexp): Use `pp-insert-short-sexp` and `widget--allow-insertion`.
This commit is contained in:
parent
129bc91a2c
commit
e819413e24
3 changed files with 44 additions and 59 deletions
|
@ -346,6 +346,23 @@ after OUT-BUFFER-NAME."
|
|||
(setq buffer-read-only nil)
|
||||
(setq-local font-lock-verbose nil)))))
|
||||
|
||||
(defun pp-insert-short-sexp (sexp &optional width)
|
||||
"Insert a short description of SEXP in the current buffer.
|
||||
WIDTH is the maximum width to use for it and it defaults to the
|
||||
space available between point and the window margin."
|
||||
(let ((printed (format "%S" sexp)))
|
||||
(if (and (not (string-search "\n" printed))
|
||||
(<= (string-width printed)
|
||||
(or width (- (window-width) (current-column)))))
|
||||
(insert printed)
|
||||
(insert-text-button
|
||||
"[Show]"
|
||||
'follow-link t
|
||||
'action (lambda (&rest _ignore)
|
||||
;; FIXME: Why "eval output"?
|
||||
(pp-display-expression sexp "*Pp Eval Output*"))
|
||||
'help-echo "mouse-2, RET: pretty print value in another buffer"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun pp-eval-expression (expression)
|
||||
"Evaluate EXPRESSION and pretty-print its value.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue