Subject: Re: bug#52459: 28.0.90; prin1-to-string does not escape bidi control characters despite print-escape-control-characters=t

From: Daniel Mendler <[email-masked]>
Date: Mon, 13 Dec 2021 14:30:13 +0100

In other words, there is a need for a functionality which makes it
possible to turn a string into a string literal in a form which could be
used in source code for example.

If you look at the definition of bidi-directional-controls-chars in
simple.el, the bidi characters are escaped there. Why is this? Why did
you write this definition in this form and not with unescaped bidi
characters?

(defvar bidi-directional-controls-chars "\x202a-\x202e\x2066-\x2069"
  "Character set that matches bidirectional formatting control characters.")

If I set `print-escape-control-characters` or some hypothetical
`print-escape-unicode-control-characters` to t, I expect a string
literal of this form. The current behavior of Emacs is counter intuitive
since it does not escape all control characters but singles out only the
ASCII control characters. This behavior does not seem correct given full
Emacs support in Emacs.

Therefore my proposal to add two variables
`print-escape-ascii-control-characters` and
`print-escape-unicode-control-characters`.