Subject: bug#67180: closed (Re: bug#67180: 30.0.50; 'pp-to-string' emits extra newline)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 16 Nov 2023 16:21:02 +0000

Your bug report

#67180: 30.0.50; 'pp-to-string' emits extra newline

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
67180: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67180
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#67180: 30.0.50; 'pp-to-string' emits extra newline
From: Stefan Monnier <[email-masked]>
To: Eshel Yaron <[email-masked]>
Cc: Eli Zaretskii <[email-masked]>, [email-masked]
Date: Thu, 16 Nov 2023 11:20:44 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

>> 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

Subject: 30.0.50; 'pp-to-string' emits extra newline
From: Eshel Yaron <[email-masked]>
To: [email-masked]
Date: Tue, 14 Nov 2023 21:12:34 +0100
List-Id: <debbugs-submit.debbugs.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\"
"

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