unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler <mail@daniel-mendler.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 52459@debbugs.gnu.org
Subject: bug#52459: 28.0.90; prin1-to-string does not escape bidi control characters despite print-escape-control-characters=t
Date: Sun, 12 Dec 2021 22:11:38 +0100	[thread overview]
Message-ID: <a83299cb-02cf-5ee3-ecf8-a97b65b9fac8@daniel-mendler.de> (raw)
In-Reply-To: <83v8ztmu75.fsf@gnu.org>

>> 1. Start emacs -Q
>> 2. Enter the following in the scratch buffer:
>> (let ((print-escape-control-characters t))
>>   (prin1-to-string bidi-directional-controls-chars))
>> 3. Evaluate. The bidi control characters are not escaped despite
>> print-escape-control-characters=t.
>>
>> The bidi characters should probably be treated as control characters
>> since they have the Bidi_Control property according to the Unicode
>> standard.
> 
> print-escape-control-characters is about ASCII control characters, not
> about Unicode fomatting controls.

I see, but this is not a satisfactory answer.

>> If it is undesirable to treat bidi control characters like other control
>> characters it may make sense to introduce another print configuration
>> variable, print-escape-all-control-characters or
>> print-escape-bidi-control-characters?
> 
> I don't think it's desirable.  Those formatting controls have starkly
> different roles that ASCII control characters, and we already have
> features to make them stand out on display.  Moreover, escape
> sequences are not well-defined for codepoints beyond a single byte.
> 
> So I don't think we should do anything here, and we should close the
> bug.

I disagree. I would like to turn this report into a feature request
then. I've observed that multiple packages which escape strings and
print them for debugging or help purposes have difficulties with bidi
characters. All I would like to have is a way to print strings safely,
such that control characters (any kind of control characters, ascii or
unicode) do not affect the output.

Example packages which are affected by this issue are for example the
Helpful package, which provides an enhanced Help buffer. Another package
affected by the issue is the Marginalia package which adds annotations
to `describe-variable` in the minibuffer. The annotations show the
variable value. I would like to print the variable values in a safe way
which does not mess up the display. Instead of "string" these packages
show "str"gnandallthatfollowsisgarbage. How is this supposed to be done?

I propose the addition of an additional variable which configures
prin1-string such that all control characters which affect the display
in special ways are escaped. Is there an alternative approach to achieve
this goal?





  reply	other threads:[~2021-12-12 21:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 20:13 bug#52459: 28.0.90; prin1-to-string does not escape bidi control characters despite print-escape-control-characters=t Daniel Mendler
2021-12-12 20:42 ` Eli Zaretskii
2021-12-12 21:11   ` Daniel Mendler [this message]
2021-12-12 21:33     ` Daniel Mendler
2021-12-13 12:22       ` Eli Zaretskii
2021-12-13 13:19         ` Daniel Mendler
2021-12-13 13:30           ` Daniel Mendler
2021-12-13 15:24             ` Eli Zaretskii
2021-12-13 16:32               ` Daniel Mendler
2021-12-13 17:07                 ` Eli Zaretskii
2021-12-13 18:13                   ` Daniel Mendler
2021-12-13 18:28                     ` Eli Zaretskii
2021-12-13 18:35                       ` Daniel Mendler
2021-12-13 18:52                         ` Eli Zaretskii
2021-12-13 18:57                           ` Daniel Mendler
2021-12-13 19:08                             ` Eli Zaretskii
2021-12-13 19:16                               ` Daniel Mendler
2021-12-13 19:38                                 ` Eli Zaretskii
2021-12-14 18:23                                   ` Dmitry Gutov
2021-12-14 18:32                                     ` Daniel Mendler
2021-12-14 18:40                                       ` Dmitry Gutov
2021-12-14 18:47                                       ` Eli Zaretskii
2021-12-14 18:51                                         ` Daniel Mendler
2021-12-14 19:41                                           ` Dmitry Gutov
2021-12-14 19:22                                       ` Andreas Schwab
2021-12-14 18:39                                     ` Eli Zaretskii
2021-12-14 18:56                                       ` Dmitry Gutov
2021-12-14 19:20                                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a83299cb-02cf-5ee3-ecf8-a97b65b9fac8@daniel-mendler.de \
    --to=mail@daniel-mendler.de \
    --cc=52459@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).