From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <83v8ztmu75.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26810"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52459@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 12 22:12:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwW8n-0006po-RK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Dec 2021 22:12:17 +0100 Original-Received: from localhost ([::1]:50968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwW8m-0001lA-7T for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Dec 2021 16:12:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwW8Z-0001ks-B6 for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 16:12:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwW8Y-0005e6-U9 for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 16:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwW8Y-0003dn-G3 for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 16:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Dec 2021 21:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52459 X-GNU-PR-Package: emacs Original-Received: via spool by 52459-submit@debbugs.gnu.org id=B52459.163934350813974 (code B ref 52459); Sun, 12 Dec 2021 21:12:02 +0000 Original-Received: (at 52459) by debbugs.gnu.org; 12 Dec 2021 21:11:48 +0000 Original-Received: from localhost ([127.0.0.1]:53294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwW8J-0003dK-P4 for submit@debbugs.gnu.org; Sun, 12 Dec 2021 16:11:48 -0500 Original-Received: from server.qxqx.de ([178.63.65.180]:43175 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwW8H-0003d7-Vp for 52459@debbugs.gnu.org; Sun, 12 Dec 2021 16:11:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BOX5z7YzQx7oD4XLHd0DPSFAGWFLF0pQZ5hsLwA9Hpk=; b=mrjFsNQxKo19qA84IfjRhlYdDD ZkWQc2zy6VE8GqLzhv/kdjFRGGHLFLrTekFjblJ8/kChzOWg5nkHxfra3i6wDpAlmFXCTa6jeCYqZ FhpCSEvDipIXu48IoPQVJnDNqzT+2453FzD66ceFA02QWbV4RH8wXm5neXrt1frqLfLU=; In-Reply-To: <83v8ztmu75.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222272 Archived-At: >> 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?