You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Protect breakpoint persistence from print-* vars (#792)
* Protect breakpoint persistence from print-* vars
The output of printing functions (including 'prin1' and, by
extension, 'format' with a '%s' sequence) is affected by a set of
output variables that both end-users and libraries can tweak.
This is fine in the more common use of these functions to format
messages, but the problem is that the same functions are also the
most convenient way to serialize/persist data.
Serialization should be robust to non-default values of
'print-length' and 'print-level' in particular, as setting these to
small numbers can lead to accidental data loss (and in some cases
unreadable output).
Starting in Emacs 29, 'prin1' and co. gained a new optional argument
precisely to protect against this problem. In the meantime, this
patch ensures that 'print-length' and 'print-level' are set to their
default values during serialization.
* Minor printing simplifications
'dap--persist': 'with-temp-file' creates a fresh buffer that is
already empty, so there is no need to erase it again. Print
data-to-persist directly to output buffer, avoiding roundtrip via
temporary string.
'dap--print-to-output-buffer': modes are enabled with a 'nil' or
nonnegative numeric argument rather than with 't'; using
'turn-on-font-lock' avoids both this pitfall, as well as redundantly
reenabling the mode. Use an 'inhibit-read-only' binding for
temporary read-only overrides, as modifications to
'buffer-read-only' will not be undone in case of a non-local exit.
'dap-debug-edit-template': Avoid temporary string roundtrip when
checking for an empty buffer. Use 'insert-char' for repetitions of
the same character. Remove redundant 'prin1-to-string' in arguments
to 'format'; it already uses 'prin1' for the '%s' sequence.
0 commit comments