GNU bug report logs -
#67180
30.0.50; 'pp-to-string' emits extra newline
Previous Next
Reported by: Eshel Yaron <me <at> eshelyaron.com>
Date: Tue, 14 Nov 2023 20:14:02 UTC
Severity: normal
Found in version 30.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67180 in the body.
You can then email your comments to 67180 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Tue, 14 Nov 2023 20:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eshel Yaron <me <at> eshelyaron.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 14 Nov 2023 20:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On Emacs 29 and earlier, with `-Q`, we have:
(pp-to-string "foo")
=> "\"foo\""
On master with `-Q`, we get an extra newline at the end of the string:
(pp-to-string "foo")
=> "\"foo\"
"
AFAICT this change in behavior breaks `agda2-mode` completely on master.
This happens because apparently `agda2-mode` uses `pp-to-string` to
quote strings before sending them to a REPL (that doesn't expect the
newline the middle of a command):
--8<---------------cut here---------------start------------->8---
(defun agda2-string-quote (s)
"..."
(let ((pp-escape-newlines t)
(s2 (copy-sequence s)))
(set-text-properties 0 (length s2) nil s2)
(mapconcat 'agda2-char-quote (pp-to-string s2) "")))
^^^^^^^^^^^^^^^^^
--8<---------------cut here---------------end--------------->8---
In GNU Emacs 30.0.50 (build 24, x86_64-apple-darwin23.0.0, NS
appkit-2487.00 Version 14.0 (Build 23A344)) of 2023-11-13
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Tue, 14 Nov 2023 20:38:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
Eshel Yaron writes:
> On Emacs 29 and earlier, with `-Q`, we have:
>
> (pp-to-string "foo")
> => "\"foo\""
>
> On master with `-Q`, we get an extra newline at the end of the string:
>
> (pp-to-string "foo")
> => "\"foo\"
> "
>
> AFAICT this change in behavior breaks `agda2-mode` completely on master...
I see that the Agda developers worked around[0] this in the development
version of `agda2-mode`, but of course more code out there may be
affected by this change. Perhaps it's worth mentioning in NEWS?
Best,
Eshel
[0] https://github.com/agda/agda/pull/6954
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Tue, 14 Nov 2023 20:38:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Wed, 15 Nov 2023 15:37:18 GMT)
Full text and
rfc822 format available.
Message #14 received at 67180 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>>> On Emacs 29 and earlier, with `-Q`, we have:
>>>
>>> (pp-to-string "foo")
>>> => "\"foo\""
>>>
>>> On master with `-Q`, we get an extra newline at the end of the string:
>>>
>>> (pp-to-string "foo")
>>> => "\"foo\"
>>> "
>
> Is that a problem?
FWIW, I think that this change is for the better, but it is
incompatible, and sadly it broke `agda2-mode`. (In some sense this
probably Agda's "fault", because I don't really understand why they're
using `pp-to-string` the way they do.) My suggestion was simply to
explicitly mention this new behavior in NEWS or some such.
> I also see that the old `pp-to-string` added that same extra newline for
> slightly more complex input:
>
> ELISP> (pp-to-string '("foo"))
> "(\"foo\")
> "
> ELISP>
>
>> Stefan, is this due to your changes in pp?
>
> Yes.
>
>
> Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Wed, 15 Nov 2023 16:29:06 GMT)
Full text and
rfc822 format available.
Message #17 received at 67180 <at> debbugs.gnu.org (full text, mbox):
> Date: Tue, 14 Nov 2023 21:12:34 +0100
> From: Eshel Yaron via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
>
> On Emacs 29 and earlier, with `-Q`, we have:
>
> (pp-to-string "foo")
> => "\"foo\""
>
> On master with `-Q`, we get an extra newline at the end of the string:
>
> (pp-to-string "foo")
> => "\"foo\"
> "
Stefan, is this due to your changes in pp?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Wed, 15 Nov 2023 16:33:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 67180 <at> debbugs.gnu.org (full text, mbox):
>> On Emacs 29 and earlier, with `-Q`, we have:
>>
>> (pp-to-string "foo")
>> => "\"foo\""
>>
>> On master with `-Q`, we get an extra newline at the end of the string:
>>
>> (pp-to-string "foo")
>> => "\"foo\"
>> "
Is that a problem?
I also see that the old `pp-to-string` added that same extra newline for
slightly more complex input:
ELISP> (pp-to-string '("foo"))
"(\"foo\")
"
ELISP>
> Stefan, is this due to your changes in pp?
Yes.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Thu, 16 Nov 2023 14:17:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 67180 <at> debbugs.gnu.org (full text, mbox):
Eshel Yaron [2023-11-15 14:10:39] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>>>> On Emacs 29 and earlier, with `-Q`, we have:
>>>>
>>>> (pp-to-string "foo")
>>>> => "\"foo\""
>>>>
>>>> On master with `-Q`, we get an extra newline at the end of the string:
>>>>
>>>> (pp-to-string "foo")
>>>> => "\"foo\"
>>>> "
>>
>> Is that a problem?
>
> FWIW, I think that this change is for the better, but it is
> incompatible, and sadly it broke `agda2-mode`. (In some sense this
> probably Agda's "fault", because I don't really understand why they're
> using `pp-to-string` the way they do.) My suggestion was simply to
> explicitly mention this new behavior in NEWS or some such.
Like this?
diff --git a/etc/NEWS b/etc/NEWS
index 23f4a8b5311..2dcb2f5664e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1099,6 +1099,9 @@ showcases all their customization options.
* Incompatible Lisp Changes in Emacs 30.1
+** 'pp' and 'pp-to-string' now always include a terminating newline.
+In the past they included a terminating newline in most cases but not all.
+
** 'buffer-match-p' and 'match-buffers' take '&rest args'.
They used to take a single '&optional arg' and were documented to use
an unreliable hack to try and support condition predicates that
-- Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67180
; Package
emacs
.
(Thu, 16 Nov 2023 15:35:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 67180 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> Eshel Yaron [2023-11-15 14:10:39] wrote:
>
>> ...My suggestion was simply to explicitly mention this new behavior
>> in NEWS or some such.
>
> Like this?
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 23f4a8b5311..2dcb2f5664e 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -1099,6 +1099,9 @@ showcases all their customization options.
>
> * Incompatible Lisp Changes in Emacs 30.1
>
> +** 'pp' and 'pp-to-string' now always include a terminating newline.
> +In the past they included a terminating newline in most cases but not all.
> +
> ** 'buffer-match-p' and 'match-buffers' take '&rest args'.
> They used to take a single '&optional arg' and were documented to use
> an unreliable hack to try and support condition predicates that
>
Exactly, yes. Thanks!
Eshel
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Thu, 16 Nov 2023 16:21:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Eshel Yaron <me <at> eshelyaron.com>
:
bug acknowledged by developer.
(Thu, 16 Nov 2023 16:21:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 67180-done <at> debbugs.gnu.org (full text, mbox):
>> Like this?
>>
>> diff --git a/etc/NEWS b/etc/NEWS
>> index 23f4a8b5311..2dcb2f5664e 100644
>> --- a/etc/NEWS
>> +++ b/etc/NEWS
>> @@ -1099,6 +1099,9 @@ showcases all their customization options.
>>
>> * Incompatible Lisp Changes in Emacs 30.1
>>
>> +** 'pp' and 'pp-to-string' now always include a terminating newline.
>> +In the past they included a terminating newline in most cases but not all.
>> +
>> ** 'buffer-match-p' and 'match-buffers' take '&rest args'.
>> They used to take a single '&optional arg' and were documented to use
>> an unreliable hack to try and support condition predicates that
>>
>
> Exactly, yes. Thanks!
Thanks, pushed to `master`.
Closing,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 15 Dec 2023 12:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 147 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.