aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS18
-rw-r--r--lisp/emacs-lisp/pp.el12
2 files changed, 20 insertions, 10 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 16d17821b78..08c7f8a4dd6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -4321,15 +4321,21 @@ whose matches are to be replaced. If these variables are nil (which
4321is the default), 'query-replace' and 'query-replace-regexp' take the 4321is the default), 'query-replace' and 'query-replace-regexp' take the
4322default value from the previous FROM-TO pair. 4322default value from the previous FROM-TO pair.
4323 4323
4324--- 4324** Lisp pretty-printer ('pp')
4325** New user option 'pp-use-max-width'.
4326If non-nil, 'pp' will attempt to limit the line length when formatting
4327long lists and vectors.
4328 4325
4329--- 4326---
4330** New function 'pp-emacs-lisp-code'. 4327*** New function 'pp-emacs-lisp-code'.
4331'pp' formats general Lisp sexps. This function does much the same, 4328'pp' formats general Lisp sexps. This function does much the same,
4332but applies formatting rules appropriate for Emacs Lisp code. 4329but applies formatting rules appropriate for Emacs Lisp code. Note
4330that this could currently be quite slow, and is thus appropriate only
4331for relatively small code fragments.
4332
4333---
4334*** New user option 'pp-use-max-width'.
4335If non-nil, 'pp' and all 'pp-*' commands that format the results, will
4336attempt to limit the line length when formatting long lists and
4337vectors. This uses 'pp-emacs-lisp-code', and thus could be slow for
4338large lists.
4333 4339
4334+++ 4340+++
4335** New function 'file-has-changed-p'. 4341** New function 'file-has-changed-p'.
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index ebda37419f7..e6e3cd6c6f4 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -47,7 +47,9 @@ Otherwise this should be a number."
47 47
48(defcustom pp-use-max-width nil 48(defcustom pp-use-max-width nil
49 "If non-nil, `pp'-related functions will try to fold lines. 49 "If non-nil, `pp'-related functions will try to fold lines.
50The target width is given by the `pp-max-width' variable." 50The target width is given by the `pp-max-width' variable.
51Note that this could slow down `pp' considerably when formatting
52large lists."
51 :type 'boolean 53 :type 'boolean
52 :version "29.1") 54 :version "29.1")
53 55
@@ -162,14 +164,15 @@ Also add the value to the front of the list in the variable `values'."
162 (message "Evaluating...") 164 (message "Evaluating...")
163 (let ((result (eval expression lexical-binding))) 165 (let ((result (eval expression lexical-binding)))
164 (values--store-value result) 166 (values--store-value result)
165 (pp-display-expression result "*Pp Eval Output*"))) 167 (pp-display-expression result "*Pp Eval Output*" pp-use-max-width)))
166 168
167;;;###autoload 169;;;###autoload
168(defun pp-macroexpand-expression (expression) 170(defun pp-macroexpand-expression (expression)
169 "Macroexpand EXPRESSION and pretty-print its value." 171 "Macroexpand EXPRESSION and pretty-print its value."
170 (interactive 172 (interactive
171 (list (read--expression "Macroexpand: "))) 173 (list (read--expression "Macroexpand: ")))
172 (pp-display-expression (macroexpand-1 expression) "*Pp Macroexpand Output*")) 174 (pp-display-expression (macroexpand-1 expression) "*Pp Macroexpand Output*"
175 pp-use-max-width))
173 176
174(defun pp-last-sexp () 177(defun pp-last-sexp ()
175 "Read sexp before point. Ignore leading comment characters." 178 "Read sexp before point. Ignore leading comment characters."
@@ -219,7 +222,8 @@ Ignores leading comment characters."
219;;;###autoload 222;;;###autoload
220(defun pp-emacs-lisp-code (sexp) 223(defun pp-emacs-lisp-code (sexp)
221 "Insert SEXP into the current buffer, formatted as Emacs Lisp code. 224 "Insert SEXP into the current buffer, formatted as Emacs Lisp code.
222Use the `pp-max-width' variable to control the desired line length." 225Use the `pp-max-width' variable to control the desired line length.
226Note that this could be slow for large SEXPs."
223 (require 'edebug) 227 (require 'edebug)
224 (let ((obuf (current-buffer))) 228 (let ((obuf (current-buffer)))
225 (with-temp-buffer 229 (with-temp-buffer