Subject: cl-print-to-string-with-limit erroneously imposes a maximum print-length of 50
From: Alan Mackenzie <[email-masked]>
To: [email-masked]
Date: Fri, 1 Sep 2023 14:17:12 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Emacs.

In cl-print-to-string-with-limit appears the following binding:

    (print-length (cond
                    ((null limit) nil)
                    ((eq limit t) print-length)
                    (t (min limit 50))))
                        ^^^^^^^^^^^^

..  This has the effect of ignoring the parameter LIMIT (unless it is
very small) and instead truncating the printed size to 50.  There is a
similar mechanism to limit print-level to 8.

Although the doc string doesn't explicitly say it won't truncate like
this, it kind of implies that LIMIT is the size it will truncate to.
This excessive truncation is a bug.

cl-print-to-string-with-limit is used by backtrace--print-to-string with
a LIMIT of 5000 to print the first line of a debug buffer.  The error
message gets rudely truncated at 50 characters with an ellipsis, e.g.:

    Debugger entered--Lisp error: (error "Invalid call to `edebug-before'.  Is your debug sp...")

..  We shouldn't be doing this.  It is irritating to the user.  Correct
would be to print:

    Debugger entered--Lisp error: (error "Invalid call to `edebug-before'.  Is your debug spec correct?")

..  I propose fixing this bug by removing these limits on print-length and
print-level in cl-print-to-string-with-limit.

-- 
Alan Mackenzie (Nuremberg, Germany).