* bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t)
@ 2014-10-30 16:58 Oleh
2014-10-31 18:16 ` Stefan Monnier
2014-10-31 19:21 ` Andreas Schwab
0 siblings, 2 replies; 4+ messages in thread
From: Oleh @ 2014-10-30 16:58 UTC (permalink / raw)
To: 18909
Hi,
To my surprise,
(prin1-to-string '(foo "bar") t)
evaluates as "(foo bar)". This seems like a bug to me, since it doesn't
conform to the doc (it's not the printed representation of the OBJECT any more).
I want to use the NOESCAPE option to obtain instead of:
(prin1-to-string '(foo.bar)) => "(foo\\.bar)"
this output:
(prin1-to-string '(foo.bar) t) => "(foo.bar)"
But the downside is that the strings are unquoted as well:
(prin1-to-string '(foo "bar") t) => "(foo bar)"
Please let me know if it's a bug or not, and maybe suggest how I can
obtain the behavior of (prin1-to-string x t) without unquoting the strings in x.
regards,
Oleh
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t)
2014-10-30 16:58 bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t) Oleh
@ 2014-10-31 18:16 ` Stefan Monnier
2014-10-31 19:21 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-10-31 18:16 UTC (permalink / raw)
To: Oleh; +Cc: 18909
I don't think you can get what you want with the current code.
The best you can do is (prin1-to-string '(foo.bar "baz")) and then
do a search-and-replace of the "\\.". But note that the "." is escaped
this way in order to avoid ambiguity with the "." used to separate the
car from the cdr of a cons cell, so you should not unescape every single
"\\.", only the ones where the reader recognizes the "." has being part
of the symbol.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t)
2014-10-30 16:58 bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t) Oleh
2014-10-31 18:16 ` Stefan Monnier
@ 2014-10-31 19:21 ` Andreas Schwab
2018-02-10 3:10 ` Noam Postavsky
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2014-10-31 19:21 UTC (permalink / raw)
To: Oleh; +Cc: 18909
Oleh <ohwoeowho@gmail.com> writes:
> To my surprise,
>
> (prin1-to-string '(foo "bar") t)
>
> evaluates as "(foo bar)". This seems like a bug to me, since it doesn't
> conform to the doc (it's not the printed representation of the OBJECT any more).
"This function outputs quoting characters when necessary to make output
that `read' can handle, whenever possible, unless the optional second
argument NOESCAPE is non-nil."
Escaping is about _all_ quotation, not only the backslash. It's the
difference between prin1 and princ.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t)
2014-10-31 19:21 ` Andreas Schwab
@ 2018-02-10 3:10 ` Noam Postavsky
0 siblings, 0 replies; 4+ messages in thread
From: Noam Postavsky @ 2018-02-10 3:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Oleh, 18909
tags 18909 notabug
close 18909
quit
Andreas Schwab <schwab@linux-m68k.org> writes:
> Oleh <ohwoeowho@gmail.com> writes:
>
>> To my surprise,
>>
>> (prin1-to-string '(foo "bar") t)
>>
>> evaluates as "(foo bar)". This seems like a bug to me, since it doesn't
>> conform to the doc (it's not the printed representation of the OBJECT any more).
>
> "This function outputs quoting characters when necessary to make output
> that `read' can handle, whenever possible, unless the optional second
> argument NOESCAPE is non-nil."
>
> Escaping is about _all_ quotation, not only the backslash. It's the
> difference between prin1 and princ.
Therefore closing as notabug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-10 3:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-30 16:58 bug#18909: 24.4.50; unexpected (prin1-to-string '(foo "bar") t) Oleh
2014-10-31 18:16 ` Stefan Monnier
2014-10-31 19:21 ` Andreas Schwab
2018-02-10 3:10 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.