From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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: Mon, 13 Dec 2021 14:22:35 +0200 Message-ID: <83r1agn184.fsf@gnu.org> References: <83v8ztmu75.fsf@gnu.org> <93d63756-f75d-c53e-de02-2e8270d07311@daniel-mendler.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13618"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52459@debbugs.gnu.org To: Daniel Mendler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 13 13:25:19 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 1mwkOM-0003Ov-48 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 13:25:18 +0100 Original-Received: from localhost ([::1]:35796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwkOK-0003R6-8c for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 07:25:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwkMA-0001fR-8Y for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 07:23:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwkM9-0001qJ-Vt for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 07:23:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwkM9-0006NF-Rj for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 07:23:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Dec 2021 12:23:01 +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.163939817324482 (code B ref 52459); Mon, 13 Dec 2021 12:23:01 +0000 Original-Received: (at 52459) by debbugs.gnu.org; 13 Dec 2021 12:22:53 +0000 Original-Received: from localhost ([127.0.0.1]:54299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwkM1-0006Mo-3T for submit@debbugs.gnu.org; Mon, 13 Dec 2021 07:22:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwkLz-0006MX-1m for 52459@debbugs.gnu.org; Mon, 13 Dec 2021 07:22:51 -0500 Original-Received: from [2001:470:142:3::e] (port=56882 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwkLq-0001ne-TJ; Mon, 13 Dec 2021 07:22:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rVk9aNPYuOW5Sqel+ac/8TFVGQLXOb5XsVhBgRHlRto=; b=q0sMaJ4zfr34 Y/bIa7hCDoEWSSKyRiWenmIopNxNy4mHgDCPF0vP19JmjLnZHsZqEVTLstk1S1TxzfJ0EQ1xYybzS doQZhli90aEVAr213mKikRNnAT6MqTEYinAF/aX4pKynAPbJL4sUCXiiHeeI2htr/iqODzdaax+Ib JoSpl2D+iyEFsZ4tb5aL1WMPFRjqFUdOXIQuGdo6M04psIzIRHy7kmZh3Q8gEUQ1iko1uP8xyNrcO Wje5BCR3EYSsUiMC4UCUevzgLN4gfBpX+GvoGkfIqoTT8sS0EV9TFngAeicHtjLFzPXx3Ntlx5k2g lYzbkpeTlQSEBNDv0GPRLA==; Original-Received: from [87.69.77.57] (port=4405 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwkLo-0006zD-NX; Mon, 13 Dec 2021 07:22:41 -0500 In-Reply-To: <93d63756-f75d-c53e-de02-2e8270d07311@daniel-mendler.de> (message from Daniel Mendler on Sun, 12 Dec 2021 22:33:50 +0100) 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:222303 Archived-At: > From: Daniel Mendler > Cc: 52459@debbugs.gnu.org > Date: Sun, 12 Dec 2021 22:33:50 +0100 > > On 12/12/21 10:11 PM, Daniel Mendler wrote: > > 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? > > There is actually one function which comes close in functionality - > `bidi-string-mark-left-to-right`. However this function is not really a > pure string manipulation function since it adds display properties. So > this function can only be used if the string is directly displayed as > is. The function is not a good fit if the resulting string is > manipulated further, truncated, etc. Sorry, I don't understand. The examples you provided are of text being displayed. Which is expected, since these controls have no other effect _except_ when the text is displayed. So why isn't the existing function bidi-string-mark-left-to-right (which was introduced precisely for the situations like you describe, and is actually used in Emacs for those purposes) the solution for the class of problems that you described? And can we agree that displaying these characters as escapes would not solve the problems you had in mind, so it is off the table for the rest of this discussion?