Subject: bug#7524: 24.0.50; backquote converts newlines in strings to "\n"

From: Mauro Aranda <[email-masked]>
Date: Thu, 22 Oct 2020 09:24:55 -0300

tags 7524 patch
quit

"Drew Adams" <[email-masked]> writes:

>> > (This is particularly messy when used in defcustom values.)
>>
>> I don't know what you're referring to.  I'll keep the bug
>> open for now, assuming that the defcustom issue will be
>> the actual bug.
>
> You're right of course about the chars "\n" and a ^J char in a Lisp
string.
>
> `defcustom' does different things in this regard, depending on the :type
(and
> whether there is a mismatch, but that's something else no doubt).
>
> See what the \n representation does, for example, with the file I sent to
> emacs-devel yesterday, thread "Variable behavior for `mouse-3' second
click at
> same spot".  Here's a direct URL to the file.
>
> http://www.emacswiki.org/emacs/mouse3.el
>
> Eval the defcustom for `mouse3-region-popup-submenus', then use `M-x
customize',
> and you'll see how messy (how wide) the display is.
>

If I understand this bug report correctly, the wishlist item is about
pretty printing restricted-sexp values, which makes sense to me.  Values
of the sexp widget already get pretty-printed, but not the values of the
restricted-sexp widget.

I attach a patch to pretty-print restricted sexp values too, by using the
same function that the sexp widget uses.
From 0cf7d7537ccbf6b68f031e47775e220607aa191e Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Wed, 7 Oct 2020 20:02:04 -0300
Subject: [PATCH] Pretty print restricted sexp values too

* lisp/wid-edit.el (restricted-sexp widget): Use
widget-sexp-value-to-internal to pretty print the widget's value, when
it is a valid one.  (Bug#7524)
---
 lisp/wid-edit.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index c3366b62cd..009c6b4faf 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3584,7 +3584,7 @@ 'restricted-sexp
   :match 'widget-restricted-sexp-match
   :value-to-internal (lambda (widget value)
 		       (if (widget-apply widget :match value)
-			   (prin1-to-string value)
+                           (widget-sexp-value-to-internal widget value)
 			 value)))
 
 (defun widget-restricted-sexp-match (widget value)
-- 
2.28.0