[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 849de5aa1a4: Correct the `cond' forms in cl-print-string-with-lim
From: |
Alan Mackenzie |
Subject: |
master 849de5aa1a4: Correct the `cond' forms in cl-print-string-with-limit |
Date: |
Tue, 3 Oct 2023 06:24:02 -0400 (EDT) |
branch: master
commit 849de5aa1a42cae6ae1504804acf0c7fb8b13860
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
Correct the `cond' forms in cl-print-string-with-limit
In this function, calling with limit bound to t will cause an
error in any of the cond forms which set print-length, etc.
Correct them!
* lisp/emacs-lisp/cl-print.el (cl-print-string-with-limit):
Amend the doc string. In the cond forms in the bindings for
print-length, etc., test the value t first. Amend those for
print-length and print-level also to test for a zero value of
limit.
---
lisp/emacs-lisp/cl-print.el | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el
index d0bfcab4082..aa495b161d6 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -549,14 +549,14 @@ node `(elisp)Output Variables'."
(defun cl-print-to-string-with-limit (print-function value limit)
"Return a string containing a printed representation of VALUE.
Attempt to get the length of the returned string under LIMIT
-characters with appropriate settings of `print-level' and
-`print-length.' Use PRINT-FUNCTION to print, which should take
-the arguments VALUE and STREAM and which should respect
-`print-length' and `print-level'. LIMIT may be nil or zero in
-which case PRINT-FUNCTION will be called with `print-level' and
-`print-length' bound to nil, and it can also be t in which case
-PRINT-FUNCTION will be called with the current values of `print-level'
-and `print-length'.
+characters with appropriate settings of `print-level',
+`print-length.', and `cl-print-string-length'. Use
+PRINT-FUNCTION to print, which should take the arguments VALUE
+and STREAM and which should respect `print-length',
+`print-level', and `cl-print-string-length'. LIMIT may be nil or
+zero in which case PRINT-FUNCTION will be called with these
+settings bound to nil, and it can also be t in which case
+PRINT-FUNCTION will be called with their current values.
Use this function with `cl-prin1' to print an object,
abbreviating it with ellipses to fit within a size limit."
@@ -565,17 +565,17 @@ abbreviating it with ellipses to fit within a size limit."
;; limited, if you increase print-level here, add more depth in
;; call_debugger (bug#31919).
(let* ((print-length (cond
- ((null limit) nil)
((eq limit t) print-length)
+ ((or (null limit) (zerop limit)) nil)
(t (min limit 50))))
(print-level (cond
- ((null limit) nil)
((eq limit t) print-level)
+ ((or (null limit) (zerop limit)) nil)
(t (min 8 (truncate (log limit))))))
(cl-print-string-length
(cond
- ((or (null limit) (zerop limit)) nil)
((eq limit t) cl-print-string-length)
+ ((or (null limit) (zerop limit)) nil)
(t (max 0 (- limit 3)))))
(delta-length (when (natnump limit)
(max 1 (truncate (/ print-length print-level))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 849de5aa1a4: Correct the `cond' forms in cl-print-string-with-limit,
Alan Mackenzie <=