[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 2a2b1d09ac: Fix minor issues with 'pp' and related commands
From: |
Eli Zaretskii |
Subject: |
emacs-29 2a2b1d09ac: Fix minor issues with 'pp' and related commands |
Date: |
Fri, 13 Jan 2023 03:40:56 -0500 (EST) |
branch: emacs-29
commit 2a2b1d09ac77f66629cb5b968d5f7e6451a2c8a9
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix minor issues with 'pp' and related commands
* etc/NEWS:
* lisp/emacs-lisp/pp.el (pp-use-max-width, pp-emacs-lisp-code):
Mention in doc string that formatting via 'pp-emacs-lisp-code'
could be slow.
(pp-eval-expression, pp-macroexpand-expression): Honor
'pp-use-max-width'. (Bug#58687)
---
etc/NEWS | 18 ++++++++++++------
lisp/emacs-lisp/pp.el | 12 ++++++++----
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 16d17821b7..08c7f8a4dd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -4321,15 +4321,21 @@ whose matches are to be replaced. If these variables
are nil (which
is the default), 'query-replace' and 'query-replace-regexp' take the
default value from the previous FROM-TO pair.
----
-** New user option 'pp-use-max-width'.
-If non-nil, 'pp' will attempt to limit the line length when formatting
-long lists and vectors.
+** Lisp pretty-printer ('pp')
---
-** New function 'pp-emacs-lisp-code'.
+*** New function 'pp-emacs-lisp-code'.
'pp' formats general Lisp sexps. This function does much the same,
-but applies formatting rules appropriate for Emacs Lisp code.
+but applies formatting rules appropriate for Emacs Lisp code. Note
+that this could currently be quite slow, and is thus appropriate only
+for relatively small code fragments.
+
+---
+*** New user option 'pp-use-max-width'.
+If non-nil, 'pp' and all 'pp-*' commands that format the results, will
+attempt to limit the line length when formatting long lists and
+vectors. This uses 'pp-emacs-lisp-code', and thus could be slow for
+large lists.
+++
** New function 'file-has-changed-p'.
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index ebda37419f..e6e3cd6c6f 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -47,7 +47,9 @@ Otherwise this should be a number."
(defcustom pp-use-max-width nil
"If non-nil, `pp'-related functions will try to fold lines.
-The target width is given by the `pp-max-width' variable."
+The target width is given by the `pp-max-width' variable.
+Note that this could slow down `pp' considerably when formatting
+large lists."
:type 'boolean
:version "29.1")
@@ -162,14 +164,15 @@ Also add the value to the front of the list in the
variable `values'."
(message "Evaluating...")
(let ((result (eval expression lexical-binding)))
(values--store-value result)
- (pp-display-expression result "*Pp Eval Output*")))
+ (pp-display-expression result "*Pp Eval Output*" pp-use-max-width)))
;;;###autoload
(defun pp-macroexpand-expression (expression)
"Macroexpand EXPRESSION and pretty-print its value."
(interactive
(list (read--expression "Macroexpand: ")))
- (pp-display-expression (macroexpand-1 expression) "*Pp Macroexpand Output*"))
+ (pp-display-expression (macroexpand-1 expression) "*Pp Macroexpand Output*"
+ pp-use-max-width))
(defun pp-last-sexp ()
"Read sexp before point. Ignore leading comment characters."
@@ -219,7 +222,8 @@ Ignores leading comment characters."
;;;###autoload
(defun pp-emacs-lisp-code (sexp)
"Insert SEXP into the current buffer, formatted as Emacs Lisp code.
-Use the `pp-max-width' variable to control the desired line length."
+Use the `pp-max-width' variable to control the desired line length.
+Note that this could be slow for large SEXPs."
(require 'edebug)
(let ((obuf (current-buffer)))
(with-temp-buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 2a2b1d09ac: Fix minor issues with 'pp' and related commands,
Eli Zaretskii <=