From unknown Tue Aug 19 10:01:23 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#44155 <44155@debbugs.gnu.org> To: bug#44155 <44155@debbugs.gnu.org> Subject: Status: Print integers as characters Reply-To: bug#44155 <44155@debbugs.gnu.org> Date: Tue, 19 Aug 2025 17:01:23 +0000 retitle 44155 Print integers as characters reassign 44155 emacs submitter 44155 Juri Linkov severity 44155 normal tag 44155 fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 22 17:11:30 2020 Received: (at submit) by debbugs.gnu.org; 22 Oct 2020 21:11:30 +0000 Received: from localhost ([127.0.0.1]:54064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVhru-0003iQ-8K for submit@debbugs.gnu.org; Thu, 22 Oct 2020 17:11:30 -0400 Received: from lists.gnu.org ([209.51.188.17]:52984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVhrs-0003iG-O6 for submit@debbugs.gnu.org; Thu, 22 Oct 2020 17:11:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVhrs-00017L-Ip for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2020 17:11:28 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:43309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVhrp-0006ys-Q2 for bug-gnu-emacs@gnu.org; Thu, 22 Oct 2020 17:11:27 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9210A1C0005 for ; Thu, 22 Oct 2020 21:11:22 +0000 (UTC) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: Print integers as characters Organization: LINKOV.NET References: <83tuv47vkn.fsf@gnu.org> <87ft6igdzi.fsf@mail.linkov.net> <837drt1qta.fsf@gnu.org> <874kmx443u.fsf@mail.linkov.net> <83k0vszw0e.fsf@gnu.org> <87d01kvbnj.fsf@mail.linkov.net> <83wnzsxln9.fsf@gnu.org> <87wnzmgd1f.fsf@mail.linkov.net> <83mu0hng0d.fsf@gnu.org> <87r1ps8xh4.fsf@mail.linkov.net> <831rhroexo.fsf@gnu.org> <87blgv60ug.fsf@mail.linkov.net> <83d01bmol5.fsf@gnu.org> <871rhr3057.fsf@mail.linkov.net> <83blgvmnpu.fsf@gnu.org> <87h7qn1i8z.fsf@mail.linkov.net> <834kmmmn5j.fsf@gnu.org> Date: Thu, 22 Oct 2020 23:56:21 +0300 In-Reply-To: <834kmmmn5j.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 22 Oct 2020 15:59:52 +0300") Message-ID: <87mu0e0ykq.fsf_-_@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=217.70.183.197; envelope-from=juri@linkov.net; helo=relay5-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/22 17:11:23 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Tags: patch [Creating a separate feature request from bug#43866] >> Let-binding a new variable 'print-integers-as-chars' to t: >> >> (let ((print-integers-as-chars t)) >> (pp '(("'A" . [?Á]) >> ("'E" . [?É]) >> ("'I" . [?Í]) >> ("'O" . [?Ó]) >> ("'U" . [?Ú]) >> ("'Y" . [?Ý])) >> (current-buffer))) >> >> prints integers as characters: >> >> (("'A" . [?Á]) >> ("'E" . [?É]) >> ("'I" . [?Í]) >> ("'O" . [?Ó]) >> ("'U" . [?Ú]) >> ("'Y" . [?Ý])) >> >> with this patch: > > The idea is fine, but I have a few comments about implementation: > >> case_Lisp_Int: >> { >> - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); >> - strout (buf, len, len, printcharfun); >> + if (!NILP (Vprint_integers_as_chars) && CHARACTERP (obj)) > ^^^^^^^^^^^^^^^^^^^^^^^^ > If this is supposed to be a boolean variable, please use DEFVAR_BOOL, > with all the consequences. Fixed in the next patch. >> + int len = sprintf (buf, "%s", SDATA (call1 (intern ("prin1-char"), obj))); > > Do we really need to call Lisp? I thought we were quite capable of > printing characters from C, aren't we? Thanks for the hint. Now the patch uses only C functions. (My initial idea was to use eval-expression-print-format as a base that has (let ((char-string (and (characterp value) (<= value eval-expression-print-maximum-character) (char-displayable-p value) (prin1-char value)))) but it seems only the condition 'characterp' is needed in C implementation.) >> @@ -2247,6 +2255,10 @@ syms_of_print (void) >> that represents the number without losing information. */); >> Vfloat_output_format = Qnil; >> >> + DEFVAR_LISP ("print-integers-as-chars", Vprint_integers_as_chars, >> + doc: /* Print integers as characters. */); >> + Vprint_integers_as_chars = Qnil; > > I wonder whether it wouldn't be cleaner to add another optional > argument to prin1, and let it bind some internal variable so that > print_object does this, instead of exposing this knob to Lisp. > Because print_object is used all over the place, and who knows what > will this do to other callers? The variable 'print-integers-as-chars' is modeled after many similar variables that affect the prin1 output: - print-escape-control-characters - print-escape-newlines - print-escape-nonascii - print-escape-multibyte - print-length - print-level - print-quoted - print-circle - float-output-format But now this leads me to think that maybe the new variable should be like 'float-output-format', so it could be named 'integer-output-format' and support options for different integer formats: - 'character': print integers as characters; - 'decimal': the default format; - 'binary': print integers as e.g. #b010101; - 'octal': print integers as e.g. #o777; - 'hex': print integers as e.g. #x00ff; --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=print-integers-as-characters.patch diff --git a/src/print.c b/src/print.c index dca095f281..909c55efed 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,16 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + if (print_integers_as_characters && CHARACTERP (obj)) + { + printchar ('?', printcharfun); + print_string (CALLN (Fstring, obj), printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2255,10 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_BOOL ("print-integers-as-characters", print_integers_as_characters, + doc: /* Print integers as characters. */); + print_integers_as_characters = 0; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 22 18:39:14 2020 Received: (at 44155) by debbugs.gnu.org; 22 Oct 2020 22:39:15 +0000 Received: from localhost ([127.0.0.1]:54145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVjEo-0005u3-Om for submit@debbugs.gnu.org; Thu, 22 Oct 2020 18:39:14 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:52080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVjEn-0005tt-0Q for 44155@debbugs.gnu.org; Thu, 22 Oct 2020 18:39:13 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CHMjW3cM2z1qsjg; Fri, 23 Oct 2020 00:39:11 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CHMjW22VYz1qy5r; Fri, 23 Oct 2020 00:39:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 5S04GPzDxWG3; Fri, 23 Oct 2020 00:39:10 +0200 (CEST) X-Auth-Info: hxrwKImC3YaD1k2kKeMwFYd61AR5wgs8kX7eWMeuF6ioxtwXmGyRJTlIsdrgsmCi Received: from igel.home (ppp-46-244-171-124.dynamic.mnet-online.de [46.244.171.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 23 Oct 2020 00:39:10 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 008842C202D; Fri, 23 Oct 2020 00:39:09 +0200 (CEST) From: Andreas Schwab To: Juri Linkov Subject: Re: bug#44155: Print integers as characters References: <83tuv47vkn.fsf@gnu.org> <87ft6igdzi.fsf@mail.linkov.net> <837drt1qta.fsf@gnu.org> <874kmx443u.fsf@mail.linkov.net> <83k0vszw0e.fsf@gnu.org> <87d01kvbnj.fsf@mail.linkov.net> <83wnzsxln9.fsf@gnu.org> <87wnzmgd1f.fsf@mail.linkov.net> <83mu0hng0d.fsf@gnu.org> <87r1ps8xh4.fsf@mail.linkov.net> <831rhroexo.fsf@gnu.org> <87blgv60ug.fsf@mail.linkov.net> <83d01bmol5.fsf@gnu.org> <871rhr3057.fsf@mail.linkov.net> <83blgvmnpu.fsf@gnu.org> <87h7qn1i8z.fsf@mail.linkov.net> <834kmmmn5j.fsf@gnu.org> <87mu0e0ykq.fsf_-_@mail.linkov.net> X-Yow: Will the third world war keep ``Bosom Buddies'' off the air? Date: Fri, 23 Oct 2020 00:39:09 +0200 In-Reply-To: <87mu0e0ykq.fsf_-_@mail.linkov.net> (Juri Linkov's message of "Thu, 22 Oct 2020 23:56:21 +0300") Message-ID: <877drh7unm.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.4 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) On Okt 22 2020, Juri Linkov wrote: > diff --git a/src/print.c b/src/print.c > index dca095f281..909c55efed 100644 > --- a/src/print.c > +++ b/src/print.c > @@ -1908,8 +1908,16 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) > { > case_Lisp_Int: > { > - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); > - strout (buf, len, len, printcharfun); > + if (print_integers_as_characters && CHARACTERP (obj)) > + { > + printchar ('?', printcharfun); > + print_string (CALLN (Fstring, obj), printcharfun); That will create ambigous output. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 23 04:58:26 2020 Received: (at 44155) by debbugs.gnu.org; 23 Oct 2020 08:58:26 +0000 Received: from localhost ([127.0.0.1]:54764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVsu1-0000kz-TE for submit@debbugs.gnu.org; Fri, 23 Oct 2020 04:58:26 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:36067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVstz-0000ki-U8 for 44155@debbugs.gnu.org; Fri, 23 Oct 2020 04:58:24 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 9A3FBFF817; Fri, 23 Oct 2020 08:58:16 +0000 (UTC) From: Juri Linkov To: Andreas Schwab Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <83tuv47vkn.fsf@gnu.org> <87ft6igdzi.fsf@mail.linkov.net> <837drt1qta.fsf@gnu.org> <874kmx443u.fsf@mail.linkov.net> <83k0vszw0e.fsf@gnu.org> <87d01kvbnj.fsf@mail.linkov.net> <83wnzsxln9.fsf@gnu.org> <87wnzmgd1f.fsf@mail.linkov.net> <83mu0hng0d.fsf@gnu.org> <87r1ps8xh4.fsf@mail.linkov.net> <831rhroexo.fsf@gnu.org> <87blgv60ug.fsf@mail.linkov.net> <83d01bmol5.fsf@gnu.org> <871rhr3057.fsf@mail.linkov.net> <83blgvmnpu.fsf@gnu.org> <87h7qn1i8z.fsf@mail.linkov.net> <834kmmmn5j.fsf@gnu.org> <87mu0e0ykq.fsf_-_@mail.linkov.net> <877drh7unm.fsf@igel.home> Date: Fri, 23 Oct 2020 11:16:55 +0300 In-Reply-To: <877drh7unm.fsf@igel.home> (Andreas Schwab's message of "Fri, 23 Oct 2020 00:39:09 +0200") Message-ID: <87sga5uxpk.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> + if (print_integers_as_characters && CHARACTERP (obj)) >> + { >> + printchar ('?', printcharfun); >> + print_string (CALLN (Fstring, obj), printcharfun); > > That will create ambigous output. No ambiguities found: (let ((strings (make-hash-table :test 'equal))) (dotimes (i (max-char)) (let ((s (string i))) (if (gethash s strings) (message "! %S %S" s (gethash s strings)) (puthash s i strings))))) From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 23 05:27:26 2020 Received: (at 44155) by debbugs.gnu.org; 23 Oct 2020 09:27:26 +0000 Received: from localhost ([127.0.0.1]:54771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVtM6-0001V0-7Y for submit@debbugs.gnu.org; Fri, 23 Oct 2020 05:27:26 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:65407) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVtM4-0001Uk-FN for 44155@debbugs.gnu.org; Fri, 23 Oct 2020 05:27:25 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 3597140003; Fri, 23 Oct 2020 09:27:16 +0000 (UTC) From: Juri Linkov To: Andreas Schwab Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <83tuv47vkn.fsf@gnu.org> <87ft6igdzi.fsf@mail.linkov.net> <837drt1qta.fsf@gnu.org> <874kmx443u.fsf@mail.linkov.net> <83k0vszw0e.fsf@gnu.org> <87d01kvbnj.fsf@mail.linkov.net> <83wnzsxln9.fsf@gnu.org> <87wnzmgd1f.fsf@mail.linkov.net> <83mu0hng0d.fsf@gnu.org> <87r1ps8xh4.fsf@mail.linkov.net> <831rhroexo.fsf@gnu.org> <87blgv60ug.fsf@mail.linkov.net> <83d01bmol5.fsf@gnu.org> <871rhr3057.fsf@mail.linkov.net> <83blgvmnpu.fsf@gnu.org> <87h7qn1i8z.fsf@mail.linkov.net> <834kmmmn5j.fsf@gnu.org> <87mu0e0ykq.fsf_-_@mail.linkov.net> <877drh7unm.fsf@igel.home> Date: Fri, 23 Oct 2020 11:32:52 +0300 In-Reply-To: <877drh7unm.fsf@igel.home> (Andreas Schwab's message of "Fri, 23 Oct 2020 00:39:09 +0200") Message-ID: <87lffxuwgn.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> + if (print_integers_as_characters && CHARACTERP (obj)) >> + { >> + printchar ('?', printcharfun); >> + print_string (CALLN (Fstring, obj), printcharfun); > > That will create ambigous output. Or do you mean: (dotimes (i (max-char)) (condition-case err (unless (eq i (read (concat "?" (string i)))) (message "%d ?%s" i (string i))) (error (message "%d ?%s ;; %s" i (string i) (error-message-string err))))) 92 ?\ ;; End of file during parsing 4194176 ?\200 ... 4194302 ?\376 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 24 15:58:28 2020 Received: (at 44155) by debbugs.gnu.org; 24 Oct 2020 19:58:29 +0000 Received: from localhost ([127.0.0.1]:35237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWPgK-0002of-Kq for submit@debbugs.gnu.org; Sat, 24 Oct 2020 15:58:28 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:49491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWPgG-0002oK-Sf for 44155@debbugs.gnu.org; Sat, 24 Oct 2020 15:58:27 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id AAB661BF207; Sat, 24 Oct 2020 19:58:15 +0000 (UTC) From: Juri Linkov To: Andreas Schwab Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> Date: Sat, 24 Oct 2020 22:53:44 +0300 In-Reply-To: <87lffxuwgn.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 23 Oct 2020 11:32:52 +0300") Message-ID: <87d0172yev.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain >>> + if (print_integers_as_characters && CHARACTERP (obj)) >>> + { >>> + printchar ('?', printcharfun); >>> + print_string (CALLN (Fstring, obj), printcharfun); >> >> That will create ambigous output. > > Or do you mean: > > (dotimes (i (max-char)) > (condition-case err > (unless (eq i (read (concat "?" (string i)))) > (message "%d ?%s" i (string i))) > (error (message "%d ?%s ;; %s" i (string i) (error-message-string err))))) > > 92 ?\ ;; End of file during parsing > 4194176 ?\200 > ... > 4194302 ?\376 Now the following patch on this code (let ((integer-output-format t)) (pp '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ 4194176) (current-buffer))) outputs (?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ 4194176) and no ambiguities found with (let ((integer-output-format t)) (dotimes (i (+ (max-char) 2)) (condition-case err (unless (eq i (read (format "%S" i))) (message "%d ?%s" i (string i))) (error (message "%d ?%s ;; %s" i (string i) (error-message-string err)))))) The list of escaped characters was taken from 'prin1-char', not from a similar list in 'print_object' in 'case Lisp_Symbol' branch. Also 'integer-output-format' prints integers in hex format when set to 16. (let ((integer-output-format 16)) (pp '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ 4194176) (current-buffer))) => (#x3b #x28 #x29 #x7b #x7d #x5b #x5d #x22 #x27 #x5c #x3fff80) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=integer-output-format.patch diff --git a/src/print.c b/src/print.c index 53aa353769..53c8c4c91a 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,29 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + EMACS_INT c = XFIXNUM (obj); + + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) && c < 4194176) + { + printchar ('?', printcharfun); + + if (escapeflag + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) + printchar ('\\', printcharfun); + print_string (Fchar_to_string (obj), printcharfun); + } + else if (INTEGERP (Vinteger_output_format) + && XFIXNUM (Vinteger_output_format) == 16 && c >= 0) + { + int len = sprintf (buf, "#x%"pI"x", (EMACS_UINT) c); + strout (buf, len, len, printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", c); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2268,13 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, + doc: /* The format used to print integers. +When 't', print integers as characters. +When a number 16, print numbers in hex format. +Otherwise, print integers in decimal format. */); + Vinteger_output_format = Qnil; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 25 13:23:04 2020 Received: (at 44155) by debbugs.gnu.org; 25 Oct 2020 17:23:04 +0000 Received: from localhost ([127.0.0.1]:37559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWjjU-0007mS-DK for submit@debbugs.gnu.org; Sun, 25 Oct 2020 13:23:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWjjT-0007ll-CM for 44155@debbugs.gnu.org; Sun, 25 Oct 2020 13:23:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38097) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWjjM-0008Qh-M4; Sun, 25 Oct 2020 13:22:56 -0400 Received: from [176.228.60.248] (port=4819 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kWjjM-0004Yl-0G; Sun, 25 Oct 2020 13:22:56 -0400 Date: Sun, 25 Oct 2020 19:22:46 +0200 Message-Id: <83mu0afcex.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87d0172yev.fsf@mail.linkov.net> (message from Juri Linkov on Sat, 24 Oct 2020 22:53:44 +0300) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Date: Sat, 24 Oct 2020 22:53:44 +0300 > Cc: 44155@debbugs.gnu.org > > + EMACS_INT c = XFIXNUM (obj); There's no need to use EMACS_INT, a character code is at most 22 bits, so it always fits into an 'int'. > + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) && c < 4194176) ^^^^^^^ Please use MAX_5_BYTE_CHAR here. Or, better yet, CHAR_BYTE8_P. And, btw, why not allow raw bytes here as well? is there some problem? > + { > + printchar ('?', printcharfun); > + > + if (escapeflag > + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' > + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) > + printchar ('\\', printcharfun); > + print_string (Fchar_to_string (obj), printcharfun); Why are you using print_string here instead of printchar? IOW, what is the difference between printing a backslash and printing any other character, that you can use printchar for the former, but not for the latter? > + else if (INTEGERP (Vinteger_output_format) > + && XFIXNUM (Vinteger_output_format) == 16 && c >= 0) If you really want to allow Vinteger_output_format to be a bignum, you cannot use XFIXNUM with it, you need to use integer_to_intmax or somesuch. Otherwise, you should use FIXNUMP instead of INTEGERP. > + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, > + doc: /* The format used to print integers. > +When 't', print integers as characters. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ But only integers that are small enough, yes? > +When a number 16, print numbers in hex format. This immediately begs the question: why cannot the value be 8 or 2? Thanks. P.S. This will eventually need a NEWS entry. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 25 15:13:11 2020 Received: (at 44155) by debbugs.gnu.org; 25 Oct 2020 19:13:11 +0000 Received: from localhost ([127.0.0.1]:37704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWlS3-0004BW-BL for submit@debbugs.gnu.org; Sun, 25 Oct 2020 15:13:11 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:53923) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWlRz-0004B3-Bw for 44155@debbugs.gnu.org; Sun, 25 Oct 2020 15:13:07 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3E79DC0002; Sun, 25 Oct 2020 19:12:59 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> Date: Sun, 25 Oct 2020 21:09:07 +0200 In-Reply-To: <83mu0afcex.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 25 Oct 2020 19:22:46 +0200") Message-ID: <87wnzenmwc.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain >> + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) && c < 4194176) > ^^^^^^^ > > Please use MAX_5_BYTE_CHAR here. Or, better yet, CHAR_BYTE8_P. Thanks, fixed. > And, btw, why not allow raw bytes here as well? is there some problem? Because of ambiguity, both these return the same value: (read (concat "?" (string 128))) => 128 (read (concat "?" (string 4194176))) => 128 >> + print_string (Fchar_to_string (obj), printcharfun); > > Why are you using print_string here instead of printchar? IOW, what > is the difference between printing a backslash and printing any other > character, that you can use printchar for the former, but not for the > latter? It was needed in earlier versions, but not now; fixed. >> + else if (INTEGERP (Vinteger_output_format) >> + && XFIXNUM (Vinteger_output_format) == 16 && c >= 0) > > If you really want to allow Vinteger_output_format to be a bignum, you > cannot use XFIXNUM with it, you need to use integer_to_intmax or > somesuch. Otherwise, you should use FIXNUMP instead of INTEGERP. Fixed. >> + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, >> + doc: /* The format used to print integers. >> +When 't', print integers as characters. > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > But only integers that are small enough, yes? Fixed the docstring as well. >> +When a number 16, print numbers in hex format. > > This immediately begs the question: why cannot the value be 8 or 2? Because octal and binary are not so widely used as hex. But variable makes room for further improvements to later support octal and binary too, and maybe string formats like in float-output-format. > P.S. This will eventually need a NEWS entry. And also updates in the Info manual will be in the final version of the patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=integer-output-format-2.patch diff --git a/src/print.c b/src/print.c index 53aa353769..b04d5023f8 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,30 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + int c = XFIXNUM (obj); + intmax_t i; + + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) && ! CHAR_BYTE8_P (c)) + { + printchar ('?', printcharfun); + if (escapeflag + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) + printchar ('\\', printcharfun); + printchar (c, printcharfun); + } + else if (INTEGERP (Vinteger_output_format) + && integer_to_intmax (Vinteger_output_format, &i) + && i == 16 && XFIXNUM (obj) >= 0) + { + int len = sprintf (buf, "#x%"pI"x", (EMACS_UINT) XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2269,13 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, + doc: /* The format used to print integers. +When 't', print characters from integers that represent characters. +When a number 16, print non-negative numbers in hex format. +Otherwise, print integers in decimal format. */); + Vinteger_output_format = Qnil; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 25 15:54:11 2020 Received: (at 44155) by debbugs.gnu.org; 25 Oct 2020 19:54:11 +0000 Received: from localhost ([127.0.0.1]:37719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWm5j-0005Bi-2W for submit@debbugs.gnu.org; Sun, 25 Oct 2020 15:54:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWm5h-0005BV-Se for 44155@debbugs.gnu.org; Sun, 25 Oct 2020 15:54:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39757) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWm5b-0008Q2-7x; Sun, 25 Oct 2020 15:54:03 -0400 Received: from [176.228.60.248] (port=2277 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kWm5a-0004dr-EZ; Sun, 25 Oct 2020 15:54:02 -0400 Date: Sun, 25 Oct 2020 21:53:53 +0200 Message-Id: <83imayf5f2.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87wnzenmwc.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 25 Oct 2020 21:09:07 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: schwab@linux-m68k.org, 44155@debbugs.gnu.org > Date: Sun, 25 Oct 2020 21:09:07 +0200 > > > And, btw, why not allow raw bytes here as well? is there some problem? > > Because of ambiguity, both these return the same value: > > (read (concat "?" (string 128))) => 128 > (read (concat "?" (string 4194176))) => 128 And why is that a problem? Alternatively, we could print raw bytes in some special way. But not treating them as characters sounds some subtlety that will be hard to explain. From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 27 16:53:16 2020 Received: (at 44155) by debbugs.gnu.org; 27 Oct 2020 20:53:16 +0000 Received: from localhost ([127.0.0.1]:46110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXVy0-0007a8-21 for submit@debbugs.gnu.org; Tue, 27 Oct 2020 16:53:16 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:33577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXVxy-0007Zv-Fj for 44155@debbugs.gnu.org; Tue, 27 Oct 2020 16:53:15 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 739FF60005; Tue, 27 Oct 2020 20:53:06 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> Date: Tue, 27 Oct 2020 22:08:12 +0200 In-Reply-To: <83imayf5f2.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 25 Oct 2020 21:53:53 +0200") Message-ID: <878sbrc317.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain >> > And, btw, why not allow raw bytes here as well? is there some problem? >> >> Because of ambiguity, both these return the same value: >> >> (read (concat "?" (string 128))) => 128 >> (read (concat "?" (string 4194176))) => 128 > > And why is that a problem? I don't know, Andreas remarked that it creates ambiguous output, and I fixed the reported problem. > Alternatively, we could print raw bytes in some special way. But not > treating them as characters sounds some subtlety that will be hard to > explain. The existing 'prin1-char' used as a reference implementation doesn't print integers like 4194176 as characters, so the patch does the same. Anyway, here is a complete patch with tests and documentation: --=-=-= Content-Type: text/x-diff; charset=iso-8859-1 Content-Disposition: inline; filename=integer-output-format-3.patch Content-Transfer-Encoding: 8bit diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi index 2cd61ad04f..f171f13779 100644 --- a/doc/lispref/streams.texi +++ b/doc/lispref/streams.texi @@ -902,3 +902,11 @@ Output Variables in the C function @code{sprintf}. For further restrictions on what you can use, see the variable's documentation string. @end defvar + +@defvar integer-output-format +This variable specifies how to print integer numbers. The default is +@code{nil}, meaning use the decimal format. When bound to @code{t}, +print integers as characters when an integer represents a character +(@pxref{Basic Char Syntax}). When bound to the number @code{16}, +print non-negative integers in the hexadecimal format. +@end defvar diff --git a/etc/NEWS b/etc/NEWS index a77c1c883e..2f7d08ad08 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1631,6 +1631,12 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 +** New variable 'integer-output-format' defines the format of integers. +When this variable is bound to the value 't', integers are printed by +printing functions as characters when an integer represents a character. +When bound to the number 16, non-negative integers are printed in the +hexadecimal format. + +++ ** 'define-globalized-minor-mode' now takes a :predicate parameter. This can be used to control which major modes the minor mode should be diff --git a/src/print.c b/src/print.c index 53aa353769..a5c56c6b48 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,31 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + int c; + intmax_t i; + + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) + { + printchar ('?', printcharfun); + if (escapeflag + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) + printchar ('\\', printcharfun); + printchar (c, printcharfun); + } + else if (INTEGERP (Vinteger_output_format) + && integer_to_intmax (Vinteger_output_format, &i) + && i == 16 && Fnatnump (obj)) + { + int len = sprintf (buf, "#x%"pI"x", (EMACS_UINT) XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2270,13 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, + doc: /* The format used to print integers. +When t, print characters from integers that represent a character. +When a number 16, print non-negative integers in the hexadecimal format. +Otherwise, by default print integers in the decimal format. */); + Vinteger_output_format = Qnil; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); diff --git a/test/src/print-tests.el b/test/src/print-tests.el index eb9572dbdf..7b026b6b21 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -383,5 +383,25 @@ print-hash-table-test (let ((print-length 1)) (format "%S" h)))))) +(print-tests--deftest print-integer-output-format () + ;; Bug#44155. + (let ((integer-output-format t) + (syms (list ?? ?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ ?Á))) + (should (equal (read (print-tests--prin1-to-string syms)) syms)) + (should (equal (print-tests--prin1-to-string syms) + (concat "(" (mapconcat #'prin1-char syms " ") ")")))) + (let ((integer-output-format t) + (syms (list -1 0 1 ?\120 4194175 4194176 (max-char) (1+ (max-char))))) + (should (equal (read (print-tests--prin1-to-string syms)) syms))) + (let ((integer-output-format 16) + (syms (list -1 0 1 most-positive-fixnum (1+ most-positive-fixnum)))) + (should (equal (read (print-tests--prin1-to-string syms)) syms)) + (should (equal (print-tests--prin1-to-string syms) + (concat "(" (mapconcat + (lambda (i) + (if (and (>= i 0) (<= i most-positive-fixnum)) + (format "#x%x" i) (format "%d" i))) + syms " ") ")"))))) + (provide 'print-tests) ;;; print-tests.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 28 11:51:39 2020 Received: (at 44155) by debbugs.gnu.org; 28 Oct 2020 15:51:39 +0000 Received: from localhost ([127.0.0.1]:50224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXnjf-0003MN-Eu for submit@debbugs.gnu.org; Wed, 28 Oct 2020 11:51:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52806) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXnjd-0003MA-TH for 44155@debbugs.gnu.org; Wed, 28 Oct 2020 11:51:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46691) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXnjX-0002Zr-BW; Wed, 28 Oct 2020 11:51:31 -0400 Received: from [176.228.60.248] (port=4953 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kXnjT-0001tx-5v; Wed, 28 Oct 2020 11:51:31 -0400 Date: Wed, 28 Oct 2020 17:51:25 +0200 Message-Id: <83h7qecps2.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <878sbrc317.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 27 Oct 2020 22:08:12 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: schwab@linux-m68k.org, 44155@debbugs.gnu.org > Date: Tue, 27 Oct 2020 22:08:12 +0200 > > > Alternatively, we could print raw bytes in some special way. But not > > treating them as characters sounds some subtlety that will be hard to > > explain. > > The existing 'prin1-char' used as a reference implementation > doesn't print integers like 4194176 as characters, so the patch > does the same. I don't think it's right, FWIW. Displaying something like \100 would be better, IMO. > +@defvar integer-output-format > +This variable specifies how to print integer numbers. The default is > +@code{nil}, meaning use the decimal format. When bound to @code{t}, > +print integers as characters when an integer represents a character > +(@pxref{Basic Char Syntax}). When bound to the number @code{16}, > +print non-negative integers in the hexadecimal format. This should mention the functions affected by the variable. > +** New variable 'integer-output-format' defines the format of integers. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "determines how to print integer values" > +When this variable is bound to the value 't', integers are printed by > +printing functions as characters when an integer represents a character. Please give at least one example of a function affected by this. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 28 16:07:00 2020 Received: (at 44155) by debbugs.gnu.org; 28 Oct 2020 20:07:00 +0000 Received: from localhost ([127.0.0.1]:50849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXrim-00080j-Gf for submit@debbugs.gnu.org; Wed, 28 Oct 2020 16:07:00 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:48703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXrik-00080T-ME for 44155@debbugs.gnu.org; Wed, 28 Oct 2020 16:06:59 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id BF1A1240003; Wed, 28 Oct 2020 20:06:51 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> Date: Wed, 28 Oct 2020 21:41:46 +0200 In-Reply-To: <83h7qecps2.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Oct 2020 17:51:25 +0200") Message-ID: <87imaury51.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain >> > Alternatively, we could print raw bytes in some special way. But not >> > treating them as characters sounds some subtlety that will be hard to >> > explain. >> >> The existing 'prin1-char' used as a reference implementation >> doesn't print integers like 4194176 as characters, so the patch >> does the same. > > I don't think it's right, FWIW. Displaying something like \100 would > be better, IMO. Sorry, I don't understand why 4194176 could be printed as \100. >> +@defvar integer-output-format >> +This variable specifies how to print integer numbers. The default is >> +@code{nil}, meaning use the decimal format. When bound to @code{t}, >> +print integers as characters when an integer represents a character >> +(@pxref{Basic Char Syntax}). When bound to the number @code{16}, >> +print non-negative integers in the hexadecimal format. > > This should mention the functions affected by the variable. > >> +** New variable 'integer-output-format' defines the format of integers. > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > "determines how to print integer values" > >> +When this variable is bound to the value 't', integers are printed by >> +printing functions as characters when an integer represents a character. > > Please give at least one example of a function affected by this. Ok, fixed: --=-=-= Content-Type: text/x-diff; charset=iso-8859-1 Content-Disposition: inline; filename=integer-output-format-4.patch Content-Transfer-Encoding: 8bit diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi index 2cd61ad04f..08d8032e6f 100644 --- a/doc/lispref/streams.texi +++ b/doc/lispref/streams.texi @@ -902,3 +902,12 @@ Output Variables in the C function @code{sprintf}. For further restrictions on what you can use, see the variable's documentation string. @end defvar + +@defvar integer-output-format +This variable specifies how to print integer numbers. The default is +@code{nil}, meaning use the decimal format. When bound to @code{t}, +print integers as characters when an integer represents a character +(@pxref{Basic Char Syntax}). When bound to the number @code{16}, +print non-negative integers in the hexadecimal format. +This variable affects all print functions. +@end defvar diff --git a/etc/NEWS b/etc/NEWS index 5e159480e0..202e449b16 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1641,6 +1641,12 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 +** New variable 'integer-output-format' determines how to print integer values. +When this variable is bound to the value 't', integers are printed by +printing functions as characters when an integer represents a character. +When bound to the number 16, non-negative integers are printed in the +hexadecimal format. + +++ ** 'define-globalized-minor-mode' now takes a :predicate parameter. This can be used to control which major modes the minor mode should be diff --git a/src/print.c b/src/print.c index 53aa353769..7b3dc61065 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,31 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + int c; + intmax_t i; + + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) + { + printchar ('?', printcharfun); + if (escapeflag + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) + printchar ('\\', printcharfun); + printchar (c, printcharfun); + } + else if (INTEGERP (Vinteger_output_format) + && integer_to_intmax (Vinteger_output_format, &i) + && i == 16 && Fnatnump (obj)) + { + int len = sprintf (buf, "#x%"pI"x", (EMACS_UINT) XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2270,15 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, + doc: /* The format used to print integers. +When t, print characters from integers that represent a character. +When a number 16, print non-negative integers in the hexadecimal format. +Otherwise, by default print integers in the decimal format. +This variable affects all print functions, for example, such function +as `print'. */); + Vinteger_output_format = Qnil; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); diff --git a/test/src/print-tests.el b/test/src/print-tests.el index eb9572dbdf..7b026b6b21 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -383,5 +383,25 @@ print-hash-table-test (let ((print-length 1)) (format "%S" h)))))) +(print-tests--deftest print-integer-output-format () + ;; Bug#44155. + (let ((integer-output-format t) + (syms (list ?? ?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ ?Á))) + (should (equal (read (print-tests--prin1-to-string syms)) syms)) + (should (equal (print-tests--prin1-to-string syms) + (concat "(" (mapconcat #'prin1-char syms " ") ")")))) + (let ((integer-output-format t) + (syms (list -1 0 1 ?\120 4194175 4194176 (max-char) (1+ (max-char))))) + (should (equal (read (print-tests--prin1-to-string syms)) syms))) + (let ((integer-output-format 16) + (syms (list -1 0 1 most-positive-fixnum (1+ most-positive-fixnum)))) + (should (equal (read (print-tests--prin1-to-string syms)) syms)) + (should (equal (print-tests--prin1-to-string syms) + (concat "(" (mapconcat + (lambda (i) + (if (and (>= i 0) (<= i most-positive-fixnum)) + (format "#x%x" i) (format "%d" i))) + syms " ") ")"))))) + (provide 'print-tests) ;;; print-tests.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 29 10:20:29 2020 Received: (at 44155) by debbugs.gnu.org; 29 Oct 2020 14:20:29 +0000 Received: from localhost ([127.0.0.1]:54526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kY8my-0003mf-TQ for submit@debbugs.gnu.org; Thu, 29 Oct 2020 10:20:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kY8mx-0003mT-KY for 44155@debbugs.gnu.org; Thu, 29 Oct 2020 10:20:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40868) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8mr-00052F-TK; Thu, 29 Oct 2020 10:20:21 -0400 Received: from [176.228.60.248] (port=3955 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kY8mc-0001Tg-JH; Thu, 29 Oct 2020 10:20:09 -0400 Date: Thu, 29 Oct 2020 16:20:06 +0200 Message-Id: <83y2jpazc9.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87imaury51.fsf@mail.linkov.net> (message from Juri Linkov on Wed, 28 Oct 2020 21:41:46 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: schwab@linux-m68k.org, 44155@debbugs.gnu.org > Date: Wed, 28 Oct 2020 21:41:46 +0200 > > >> The existing 'prin1-char' used as a reference implementation > >> doesn't print integers like 4194176 as characters, so the patch > >> does the same. > > > > I don't think it's right, FWIW. Displaying something like \100 would > > be better, IMO. > > Sorry, I don't understand why 4194176 could be printed as \100. I meant \200, sorry. That's the raw byte that 4194176 stands for. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 29 17:24:03 2020 Received: (at 44155) by debbugs.gnu.org; 29 Oct 2020 21:24:03 +0000 Received: from localhost ([127.0.0.1]:55109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFOt-0001pY-Jn for submit@debbugs.gnu.org; Thu, 29 Oct 2020 17:24:03 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:46771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFOs-0001p2-Eb for 44155@debbugs.gnu.org; Thu, 29 Oct 2020 17:24:02 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B40AF1BF204; Thu, 29 Oct 2020 21:23:55 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> Date: Thu, 29 Oct 2020 23:00:48 +0200 In-Reply-To: <83y2jpazc9.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 29 Oct 2020 16:20:06 +0200") Message-ID: <87imaskarj.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain >> >> The existing 'prin1-char' used as a reference implementation >> >> doesn't print integers like 4194176 as characters, so the patch >> >> does the same. >> > >> > I don't think it's right, FWIW. Displaying something like \100 would >> > be better, IMO. >> >> Sorry, I don't understand why 4194176 could be printed as \100. > > I meant \200, sorry. That's the raw byte that 4194176 stands for. OK, in this patch the condition !CHAR_BYTE8_P(c) is removed, so it prints \200: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=integer-output-format-4.patch diff --git a/src/print.c b/src/print.c index 53aa353769..20841eba61 100644 --- a/src/print.c +++ b/src/print.c @@ -1908,8 +1908,31 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) { case_Lisp_Int: { - int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); - strout (buf, len, len, printcharfun); + int c; + intmax_t i; + + if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) + && (c = XFIXNUM (obj))) + { + printchar ('?', printcharfun); + if (escapeflag + && (c == ';' || c == '(' || c == ')' || c == '{' || c == '}' + || c == '[' || c == ']' || c == '\"' || c == '\'' || c == '\\')) + printchar ('\\', printcharfun); + printchar (c, printcharfun); + } + else if (INTEGERP (Vinteger_output_format) + && integer_to_intmax (Vinteger_output_format, &i) + && i == 16 && !NILP (Fnatnump (obj))) + { + int len = sprintf (buf, "#x%"pI"x", (EMACS_UINT) XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } + else + { + int len = sprintf (buf, "%"pI"d", XFIXNUM (obj)); + strout (buf, len, len, printcharfun); + } } break; @@ -2247,6 +2270,13 @@ syms_of_print (void) that represents the number without losing information. */); Vfloat_output_format = Qnil; + DEFVAR_LISP ("integer-output-format", Vinteger_output_format, + doc: /* The format used to print integers. +When t, print characters from integers that represent a character. +When a number 16, print non-negative integers in the hexadecimal format. +Otherwise, by default print integers in the decimal format. */); + Vinteger_output_format = Qnil; + DEFVAR_LISP ("print-length", Vprint_length, doc: /* Maximum length of list to print before abbreviating. A value of nil means no limit. See also `eval-expression-print-length'. */); --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 30 03:35:34 2020 Received: (at 44155) by debbugs.gnu.org; 30 Oct 2020 07:35:34 +0000 Received: from localhost ([127.0.0.1]:55944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYOwf-00075f-TK for submit@debbugs.gnu.org; Fri, 30 Oct 2020 03:35:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYOwd-00075T-Dn for 44155@debbugs.gnu.org; Fri, 30 Oct 2020 03:35:32 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55996) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYOwW-0005t4-CT; Fri, 30 Oct 2020 03:35:25 -0400 Received: from [176.228.60.248] (port=3611 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kYOwV-0000xL-NZ; Fri, 30 Oct 2020 03:35:24 -0400 Date: Fri, 30 Oct 2020 09:35:06 +0200 Message-Id: <83lffob1zp.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87imaskarj.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 29 Oct 2020 23:00:48 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: schwab@linux-m68k.org, 44155@debbugs.gnu.org > Date: Thu, 29 Oct 2020 23:00:48 +0200 > > > I meant \200, sorry. That's the raw byte that 4194176 stands for. > > OK, in this patch the condition !CHAR_BYTE8_P(c) is removed, so > it prints \200: Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 31 16:11:58 2020 Received: (at 44155) by debbugs.gnu.org; 31 Oct 2020 20:11:58 +0000 Received: from localhost ([127.0.0.1]:34618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYxEE-0007OE-3S for submit@debbugs.gnu.org; Sat, 31 Oct 2020 16:11:58 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:45877) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYxEC-0007Ny-PR; Sat, 31 Oct 2020 16:11:57 -0400 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id A619A1C0002; Sat, 31 Oct 2020 20:11:49 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> Date: Sat, 31 Oct 2020 22:11:24 +0200 In-Reply-To: <83lffob1zp.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 30 Oct 2020 09:35:06 +0200") Message-ID: <87pn4ynok3.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 44155 fixed close 44155 28.0.50 quit >> > I meant \200, sorry. That's the raw byte that 4194176 stands for. >> >> OK, in this patch the condition !CHAR_BYTE8_P(c) is removed, so >> it prints \200: > > Thanks. Now pushed to master and closed. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 31 19:27:19 2020 Received: (at 44155) by debbugs.gnu.org; 31 Oct 2020 23:27:19 +0000 Received: from localhost ([127.0.0.1]:34898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZ0HH-00040c-Kx for submit@debbugs.gnu.org; Sat, 31 Oct 2020 19:27:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZ0HG-00040Q-5w for 44155@debbugs.gnu.org; Sat, 31 Oct 2020 19:27:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45426) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZ0H9-0003Yp-Fk; Sat, 31 Oct 2020 19:27:11 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1kZ0H4-0005S7-Lw; Sat, 31 Oct 2020 19:27:07 -0400 From: Glenn Morris To: Juri Linkov Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> X-Spook: MIT-LL enforcers import Social media Guantanamo ARPA X-Ran: V5kPy~c|N+`l5oOQe:\}ILY_AOhp$mk4ZjY7?&799*!\3r/}lR30nki9L.`^M8e"sHtA%\ X-Hue: brightwhite X-Attribution: GM Date: Sat, 31 Oct 2020 19:27:05 -0400 In-Reply-To: <87pn4ynok3.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 31 Oct 2020 22:11:24 +0200") Message-ID: <1pimaq6kom.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Eli Zaretskii , schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) New test fails on some systems. Ref: https://hydra.nixos.org/build/129474379 Reproduced on CentOS 8.2. Test print-integer-output-format condition: (ert-test-failed ((should (equal (read ...) syms)) :form (equal (-1 0 1 80 4194175 128 255 4194304) (-1 0 1 80 4194175 4194176 4194303 4194304)) :value nil :explanation (list-elt 5 (different-atoms (128 "#x80" "?") (4194176 "#x3fff80" "?\200"))))) FAILED 19/39 print-integer-output-format (0.002202 sec) From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 03:01:18 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 08:01:18 +0000 Received: from localhost ([127.0.0.1]:35530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZ8Ig-0000Mp-5U for submit@debbugs.gnu.org; Sun, 01 Nov 2020 03:01:18 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:56191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZ8Id-0000MB-4A for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 03:01:16 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id F1998C0009; Sun, 1 Nov 2020 08:01:06 +0000 (UTC) From: Juri Linkov To: Glenn Morris Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> Date: Sun, 01 Nov 2020 09:58:25 +0200 In-Reply-To: <1pimaq6kom.fsf@fencepost.gnu.org> (Glenn Morris's message of "Sat, 31 Oct 2020 19:27:05 -0400") Message-ID: <87v9epa4we.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Eli Zaretskii , schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > New test fails on some systems. > > (equal > (-1 0 1 80 4194175 128 255 4194304) > (-1 0 1 80 4194175 4194176 4194303 4194304)) > :value nil :explanation > (list-elt 5 > (different-atoms > (128 "#x80" "?") > (4194176 "#x3fff80" "?\200"))))) This is because 4194176 is printed as ?\200 that is parsed as 128. This patch should fix test failures by printing integers for ambiguous characters. I'm sure no user would complain that numbers between 4194176 and 4194303 are printed as integers. diff --git a/src/print.c b/src/print.c index fa65a3cb26..49daf753bd 100644 --- a/src/print.c +++ b/src/print.c @@ -1912,7 +1912,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) intmax_t i; if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) - && (c = XFIXNUM (obj))) + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) { printchar ('?', printcharfun); if (escapeflag From unknown Tue Aug 19 10:01:23 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug No longer marked as fixed in versions 28.0.50 and reopened. Date: Sun, 01 Nov 2020 12:04:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug No longer marked as fixed in versions 28.0.50 and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 07:04:02 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 12:04:02 +0000 Received: from localhost ([127.0.0.1]:35813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZC5Z-0004UD-NN for submit@debbugs.gnu.org; Sun, 01 Nov 2020 07:04:02 -0500 Received: from mail80c50.megamailservers.eu ([91.136.10.90]:38506 helo=mail70c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZC5W-0004Tx-4w; Sun, 01 Nov 2020 07:04:00 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604232235; bh=+Opd/8pOK+FOQhy8IQQzl3IAo8K/kvr1NIFYqHysDko=; h=From:Date:Subject:Cc:To:From; b=j2dwAd+KzSzQaGX9llcJAcqHrr3fjTJ9/vDGQkLP8plthNXRjyBYoijqHV1y5juE3 mILB05iTDBEw9eUNimLyOC0vxo+f/GVARLwRLIsDIvnkdBrRKD6JYYayFWXZbgRFpG L0O8GctUBbnE+b36tk9EQK4CJn+/NnDII7DKjD9w= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A1C3qgq002471; Sun, 1 Nov 2020 12:03:54 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Date: Sun, 1 Nov 2020 13:03:52 +0100 Subject: Re: bug#44155: Print integers as characters To: Juri Linkov , Eli Zaretskii , Andreas Schwab Message-Id: X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F23.5F9EA42B.005E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OKBZIhSB c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=GaJM6Y1Rso56rlZnNj0A:9 a=QEXdDO2ut3YA:10 X-Origin-Country: SE X-Spam-Score: 4.8 (++++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: reopen 44155 stop I don't mind the basic idea, but I'm reopening the bug since it looks like there is some unfinished business. Hope you don't mind. > When t, print characters from integers that represent a character. Content analysis details: (4.8 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 TRACKER_ID BODY: Incorporates a tracking ID number 0.5 PDS_BTC_ID FP reduced Bitcoin ID 2.9 FAKE_REPLY_B No description available. 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 3.4 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: reopen 44155 stop I don't mind the basic idea, but I'm reopening the bug since it looks like there is some unfinished business. Hope you don't mind. > When t, print characters from integers that represent a character. Content analysis details: (3.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 TRACKER_ID BODY: Incorporates a tracking ID number -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.5 PDS_BTC_ID FP reduced Bitcoin ID 2.9 FAKE_REPLY_B No description available. reopen 44155 stop I don't mind the basic idea, but I'm reopening the bug since it looks = like there is some unfinished business. Hope you don't mind. > When t, print characters from integers that represent a character. In what way does 't' suggest a character? Wouldn't something like = 'character' be more suggestive? The variable isn't named 'print-integers-as-chars'. > When a number 16, print non-negative integers in the hexadecimal = format. Doesn't work for bignums: (let ((integer-output-format 16)) (print 394583945873948753948539845)) 394583945873948753948539845 This must be a bug since there is no reason why bignums should be = treated specially. In general we try hard not to. Since there is a read syntax for binary and octal numbers as well, why = not permit 2 and 8? (And why not print negative numbers in the selected radix?) And C0/C1 controls aren't printed well: (let ((integer-output-format t)) (print 10) (print 127)) ? ?=7F^? I strongly suggest that the controls that have special escapes, like \n, = use them. What to use for the rest depends on the user's preference = really -- for example, 31 might be printed as 31, ?\037, #o37 or #x1f. Whether to print 32 as ?=E2=80=B9SPACE=E2=80=BA or ?\s is a matter of = taste. For that matter, the variable name should perhaps start with 'print-' = like other variables that control printing. Maybe we should separate the = default radix and print integers as characters? Thus, we'd have: print-integer-radix -- 2, 8, 16, 10 or nil (which means 10) print-integers-as-characters -- nil or t From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 10:14:08 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 15:14:08 +0000 Received: from localhost ([127.0.0.1]:38141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZF3Y-0003ZS-D0 for submit@debbugs.gnu.org; Sun, 01 Nov 2020 10:14:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZF3V-0003Yq-T9 for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 10:14:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55860) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZF3P-0005R0-O4; Sun, 01 Nov 2020 10:14:00 -0500 Received: from [176.228.60.248] (port=2280 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kZF3O-0003QV-9N; Sun, 01 Nov 2020 10:13:58 -0500 Date: Sun, 01 Nov 2020 17:13:46 +0200 Message-Id: <83wnz5f6tx.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <87v9epa4we.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 01 Nov 2020 09:58:25 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: Eli Zaretskii , 44155@debbugs.gnu.org, > schwab@linux-m68k.org > Date: Sun, 01 Nov 2020 09:58:25 +0200 > > > New test fails on some systems. > > > > (equal > > (-1 0 1 80 4194175 128 255 4194304) > > (-1 0 1 80 4194175 4194176 4194303 4194304)) > > :value nil :explanation > > (list-elt 5 > > (different-atoms > > (128 "#x80" "?") > > (4194176 "#x3fff80" "?\200"))))) > > This is because 4194176 is printed as ?\200 that is parsed as 128. > > This patch should fix test failures by printing integers > for ambiguous characters. I'm sure no user would complain > that numbers between 4194176 and 4194303 are printed as integers. > > diff --git a/src/print.c b/src/print.c > index fa65a3cb26..49daf753bd 100644 > --- a/src/print.c > +++ b/src/print.c > @@ -1912,7 +1912,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) > intmax_t i; > > if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) > - && (c = XFIXNUM (obj))) > + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) > { > printchar ('?', printcharfun); > if (escapeflag If a test fails, it is better to fix the test and not make the code less powerful, don't you agree? To produce 4194176 from ?\200, one way is this: (decode-char 'eight-bit ?\200) Can't this be used in the test? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 13:40:52 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 18:40:52 +0000 Received: from localhost ([127.0.0.1]:38475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZIHb-0000Nl-N5 for submit@debbugs.gnu.org; Sun, 01 Nov 2020 13:40:51 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:50265) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZIHZ-0000NC-Do for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 13:40:50 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 78C391C0002; Sun, 1 Nov 2020 18:40:40 +0000 (UTC) From: Juri Linkov To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: Date: Sun, 01 Nov 2020 20:35:33 +0200 In-Reply-To: ("Mattias =?iso-8859-1?Q?Engdeg=E5rd=22's?= message of "Sun, 1 Nov 2020 13:03:52 +0100") Message-ID: <871rhd3peq.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Andreas Schwab , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) > reopen 44155 > stop > > I don't mind the basic idea, but I'm reopening the bug since it looks > like there is some unfinished business. Hope you don't mind. Thanks for bringing a fresh perspective to this feature request. >> When t, print characters from integers that represent a character. > > In what way does 't' suggest a character? Wouldn't something like 'character' be more suggestive? > The variable isn't named 'print-integers-as-chars'. As the most frequent usage pattern, 't' is more convenient to use in code: (let ((integer-output-format t)) whereas this would be uglier and harder to type with: (let ((integer-output-format 'character)) >> When a number 16, print non-negative integers in the hexadecimal format. > > Doesn't work for bignums: > > (let ((integer-output-format 16)) > (print 394583945873948753948539845)) > > 394583945873948753948539845 Yes, this is known current limitation. > This must be a bug since there is no reason why bignums should be treated specially. > In general we try hard not to. I agree, support for big numbers should be added as well. > Since there is a read syntax for binary and octal numbers as well, why not permit 2 and 8? > (And why not print negative numbers in the selected radix?) 2 and 8 could be added as well. > And C0/C1 controls aren't printed well: > > (let ((integer-output-format t)) > (print 10) > (print 127)) > > ? > > > ?^? > > I strongly suggest that the controls that have special escapes, like > \n, use them. prin1-char uses more readable format, is this better? (prin1-char 10) ?\C-j (prin1-char 127) ?\C-? Or should 10 be printed as '?\n'? > What to use for the rest depends on the user's preference really -- > for example, 31 might be printed as 31, ?\037, #o37 or #x1f. Maybe more user choices should be supported by the variable? > Whether to print 32 as ?‹SPACE› or ?\s is a matter of taste. ?\s is less error-prone. > For that matter, the variable name should perhaps start with 'print-' > like other variables that control printing. Maybe we should separate > the default radix and print integers as characters? Thus, we'd have: The variable name was modeled after the similar variable float-output-format. > print-integer-radix -- 2, 8, 16, 10 or nil (which means 10) > > print-integers-as-characters -- nil or t What should be printed when both variables are bound to non-default values, e.g. print-integers-as-characters to t, and print-integer-radix to 16? Maybe to print with character syntax and the given radix, e.g. '?\x1f'. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 13:40:55 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 18:40:55 +0000 Received: from localhost ([127.0.0.1]:38478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZIHe-0000O2-W9 for submit@debbugs.gnu.org; Sun, 01 Nov 2020 13:40:55 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:56559) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZIHc-0000NS-TK for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 13:40:53 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 172251BF205; Sun, 1 Nov 2020 18:40:44 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> <83wnz5f6tx.fsf@gnu.org> Date: Sun, 01 Nov 2020 20:39:48 +0200 In-Reply-To: <83wnz5f6tx.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 01 Nov 2020 17:13:46 +0200") Message-ID: <877dr52ai7.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> This is because 4194176 is printed as ?\200 that is parsed as 128. >> >> This patch should fix test failures by printing integers >> for ambiguous characters. I'm sure no user would complain >> that numbers between 4194176 and 4194303 are printed as integers. >> >> if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) >> - && (c = XFIXNUM (obj))) >> + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) > > If a test fails, it is better to fix the test and not make the code > less powerful, don't you agree? This means sweeping the problems under the carpet. > To produce 4194176 from ?\200, one way is this: > > (decode-char 'eight-bit ?\200) > > Can't this be used in the test? Using this code in tests means that the users should use the same code in their programs. Thus 'print' should print '(33 4194176) as such ugly code: `(?! ,(decode-char 'eight-bit ?\200)) From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 13:52:29 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 18:52:29 +0000 Received: from localhost ([127.0.0.1]:38497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZISq-0000h0-Sh for submit@debbugs.gnu.org; Sun, 01 Nov 2020 13:52:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZISp-0000gm-Ft for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 13:52:27 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59190) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZISi-00069N-VW; Sun, 01 Nov 2020 13:52:20 -0500 Received: from [176.228.60.248] (port=4048 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kZIST-0007E2-F1; Sun, 01 Nov 2020 13:52:07 -0500 Date: Sun, 01 Nov 2020 20:51:54 +0200 Message-Id: <831rhcgbat.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <877dr52ai7.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 01 Nov 2020 20:39:48 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> <83wnz5f6tx.fsf@gnu.org> <877dr52ai7.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: rgm@gnu.org, 44155@debbugs.gnu.org, schwab@linux-m68k.org > Date: Sun, 01 Nov 2020 20:39:48 +0200 > > >> if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) > >> - && (c = XFIXNUM (obj))) > >> + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) > > > > If a test fails, it is better to fix the test and not make the code > > less powerful, don't you agree? > > This means sweeping the problems under the carpet. Which problem? > > (decode-char 'eight-bit ?\200) > > > > Can't this be used in the test? > > Using this code in tests means that the users should use the same code > in their programs. Why would they need to do that? The test needs it because it wants to verify the result, but "normal" programs don't need to read back the values they printed. > Thus 'print' should print '(33 4194176) as such ugly code: > `(?! ,(decode-char 'eight-bit ?\200)) I don't see why. ?\200 and 4194176 are two forms of the same character. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 14:14:04 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 19:14:04 +0000 Received: from localhost ([127.0.0.1]:38540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZInj-0001EY-UZ for submit@debbugs.gnu.org; Sun, 01 Nov 2020 14:14:04 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:34767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZIni-0001Dw-0Z for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 14:14:02 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B8CB2C0006; Sun, 1 Nov 2020 19:13:53 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> <83wnz5f6tx.fsf@gnu.org> <877dr52ai7.fsf@mail.linkov.net> <831rhcgbat.fsf@gnu.org> Date: Sun, 01 Nov 2020 21:13:03 +0200 In-Reply-To: <831rhcgbat.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 01 Nov 2020 20:51:54 +0200") Message-ID: <877dr4zy9s.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> >> if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) >> >> - && (c = XFIXNUM (obj))) >> >> + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) >> > >> > If a test fails, it is better to fix the test and not make the code >> > less powerful, don't you agree? >> >> This means sweeping the problems under the carpet. > > Which problem? Problem of ambiguous numbers 128 and 4194176 that are both printed as ?\200. >> > (decode-char 'eight-bit ?\200) >> > >> > Can't this be used in the test? >> >> Using this code in tests means that the users should use the same code >> in their programs. > > Why would they need to do that? The test needs it because it wants to > verify the result, but "normal" programs don't need to read back the > values they printed. Programs print the lists of characters, and other programs read them. >> Thus 'print' should print '(33 4194176) as such ugly code: >> `(?! ,(decode-char 'eight-bit ?\200)) > > I don't see why. ?\200 and 4194176 are two forms of the same > character. ?\200 and 128 are two forms of the same character too. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 14:42:12 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 19:42:12 +0000 Received: from localhost ([127.0.0.1]:38605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZJEx-0001zQ-Qj for submit@debbugs.gnu.org; Sun, 01 Nov 2020 14:42:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZJEw-0001zB-4s for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 14:42:10 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59809) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZJEp-000498-J6; Sun, 01 Nov 2020 14:42:03 -0500 Received: from [176.228.60.248] (port=3339 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kZJEn-0002Id-GL; Sun, 01 Nov 2020 14:42:01 -0500 Date: Sun, 01 Nov 2020 21:41:49 +0200 Message-Id: <83pn4weuf6.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <877dr4zy9s.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 01 Nov 2020 21:13:03 +0200) Subject: Re: bug#44155: Print integers as characters References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> <83wnz5f6tx.fsf@gnu.org> <877dr52ai7.fsf@mail.linkov.net> <831rhcgbat.fsf@gnu.org> <877dr4zy9s.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Juri Linkov > Cc: rgm@gnu.org, 44155@debbugs.gnu.org, schwab@linux-m68k.org > Date: Sun, 01 Nov 2020 21:13:03 +0200 > > >> >> if (EQ (Vinteger_output_format, Qt) && CHARACTERP (obj) > >> >> - && (c = XFIXNUM (obj))) > >> >> + && (c = XFIXNUM (obj)) && ! CHAR_BYTE8_P (c)) > >> > > >> > If a test fails, it is better to fix the test and not make the code > >> > less powerful, don't you agree? > >> > >> This means sweeping the problems under the carpet. > > > > Which problem? > > Problem of ambiguous numbers 128 and 4194176 that are both printed as ?\200. Octal escapes are generally a sign of a raw byte. This is not different from buffer display -- how do you know what does ?\200 mean inside buffer text? > ?\200 and 128 are two forms of the same character too. See my question above. I don't think what you say is true. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 15:17:23 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 20:17:24 +0000 Received: from localhost ([127.0.0.1]:38687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZJn1-0002vB-N1 for submit@debbugs.gnu.org; Sun, 01 Nov 2020 15:17:23 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:53745) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZJn0-0002uw-1A for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 15:17:22 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 24B7640004; Sun, 1 Nov 2020 20:17:13 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <877drh7unm.fsf@igel.home> <87lffxuwgn.fsf@mail.linkov.net> <87d0172yev.fsf@mail.linkov.net> <83mu0afcex.fsf@gnu.org> <87wnzenmwc.fsf@mail.linkov.net> <83imayf5f2.fsf@gnu.org> <878sbrc317.fsf@mail.linkov.net> <83h7qecps2.fsf@gnu.org> <87imaury51.fsf@mail.linkov.net> <83y2jpazc9.fsf@gnu.org> <87imaskarj.fsf@mail.linkov.net> <83lffob1zp.fsf@gnu.org> <87pn4ynok3.fsf@mail.linkov.net> <1pimaq6kom.fsf@fencepost.gnu.org> <87v9epa4we.fsf@mail.linkov.net> <83wnz5f6tx.fsf@gnu.org> <877dr52ai7.fsf@mail.linkov.net> <831rhcgbat.fsf@gnu.org> <877dr4zy9s.fsf@mail.linkov.net> <83pn4weuf6.fsf@gnu.org> Date: Sun, 01 Nov 2020 22:16:51 +0200 In-Reply-To: <83pn4weuf6.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 01 Nov 2020 21:41:49 +0200") Message-ID: <87361sx26k.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, rgm@gnu.org, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> Problem of ambiguous numbers 128 and 4194176 that are both printed as ?\200. > > Octal escapes are generally a sign of a raw byte. This is not > different from buffer display -- how do you know what does ?\200 mean > inside buffer text? > >> ?\200 and 128 are two forms of the same character too. > > See my question above. I don't think what you say is true. Typing 'C-x C-e' after ?\200 displays: 128 (#o200, #x80, ?\x80) From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 15:52:21 2020 Received: (at 44155) by debbugs.gnu.org; 1 Nov 2020 20:52:21 +0000 Received: from localhost ([127.0.0.1]:38727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZKKr-0003lz-6v for submit@debbugs.gnu.org; Sun, 01 Nov 2020 15:52:21 -0500 Received: from mail79c50.megamailservers.eu ([91.136.10.89]:57304 helo=mail70c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZKKo-0003ln-Cf for 44155@debbugs.gnu.org; Sun, 01 Nov 2020 15:52:19 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604263936; bh=DoGNgfCylmswWlRFHhO6ISIJLBGSoVp7VdslascUVNI=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=snazuK1Y8uZY50CLrAOCCCpQqa4jfa63tOzY87FAugIG1ueuPOVBCQtxdbj4rq8SF TJ9mLEq89Hg8xSXI0SS+kX1MfPOAzaZ0clKcIMxCKtYIOzR/hCaiRhneRa4Rm7FU/v AKrtaNxZwgmIUSQaV/r1/SF2pYUTSvobdEqIFd/g= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A1KqDnk023427; Sun, 1 Nov 2020 20:52:15 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <871rhd3peq.fsf@mail.linkov.net> Date: Sun, 1 Nov 2020 21:52:13 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> References: <871rhd3peq.fsf@mail.linkov.net> To: Juri Linkov X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F1C.5F9F2000.002E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OKBZIhSB c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=ucMQw-l_AAAA:8 a=cQ7_6-hZ4EWDXOCf840A:9 a=QEXdDO2ut3YA:10 a=xkTruGkd22MpkFU079mG:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 1 nov. 2020 kl. 19.35 skrev Juri Linkov : > Thanks for bringing a fresh perspective to this feature request. You are very graceful. The devil is in the details, as always! Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Andreas Schwab , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 1 nov. 2020 kl. 19.35 skrev Juri Linkov : > Thanks for bringing a fresh perspective to this feature request. You are very graceful. The devil is in the details, as always! > (prin1-char 10) ?\C-j > (prin1-char 127) ?\C-? >=20 > Or should 10 be printed as '?\n'? Yes, I think ?\n is more useful. As a character, 10 is more commonly = thought of as newline than as control-j. >> What to use for the rest depends on the user's preference really -- >> for example, 31 might be printed as 31, ?\037, #o37 or #x1f. >=20 > Maybe more user choices should be supported by the variable? Maybe, but only if we can identify sensible such choices. Otherwise we = should just try to pick the best representation in each case. Giving = users too much choice isn't necessarily making them a favour! I'd suggest plain number syntax for control characters without named = escapes, for several reasons: * Such numbers are less likely to represent characters and more likely = to be, well, numbers. * It would allow a separate radix control to govern their output format. * Writing ?\x1f is no clearer than #x1f, and sometimes more confusing: = \xff is a raw byte in a string, but ?\xff is always 255. Thus we would have 10 -> ?\n, 13 -> ?\r, 127 -> ?\d, 65 -> ?A, 255 -> = ?=C3=BF, but 31 -> 31, 129 -> 129, 4194303 -> 4194303. >> Whether to print 32 as ?=E2=80=B9SPACE=E2=80=BA or ?\s is a matter of = taste. >=20 > ?\s is less error-prone. Yes, I agree. (I prefer ?\s or 32 as characters, but " " in strings.) >> For that matter, the variable name should perhaps start with 'print-' >> like other variables that control printing. Maybe we should separate >> the default radix and print integers as characters? Thus, we'd have: >=20 > The variable name was modeled after the similar variable = float-output-format. I see, interesting! One possibility would be to use a string in the same = way, thus "%x", "%c" etc, but it makes less sense for integers than = floating-point: no precision field, and many format alternatives such as = %#x do not produce valid Lisp read syntax. Better keep it simple. >> print-integer-radix -- 2, 8, 16, 10 or nil (which means 10) >>=20 >> print-integers-as-characters -- nil or t >=20 > What should be printed when both variables are bound to non-default = values, > e.g. print-integers-as-characters to t, and print-integer-radix to 16? > Maybe to print with character syntax and the given radix, e.g. = '?\x1f'. Well, it should clearly use character syntax for printable characters = and the given radix for non-characters. As you correctly point out, what = to use for non-printable characters (C0 and C1 controls, raw bytes) is = less obvious. I'd probably just use the given radix; I see no = readability advantage in printing ?\x1f to #x1f. Since your original motivation was to print characters in pretty-printed = nested Lisp expressions, perhaps we should just define = print-integers-as-characters as a Boolean and skip the radix for the = time being? We could add a print radix control later on if desired. = (That would save us the hassle to deal with bignums, for that matter.) From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 02 16:43:28 2020 Received: (at 44155) by debbugs.gnu.org; 2 Nov 2020 21:43:28 +0000 Received: from localhost ([127.0.0.1]:42789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZhbr-00041q-S7 for submit@debbugs.gnu.org; Mon, 02 Nov 2020 16:43:28 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:55179) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZhbq-00041Q-4T for 44155@debbugs.gnu.org; Mon, 02 Nov 2020 16:43:26 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B97241BF205; Mon, 2 Nov 2020 21:43:18 +0000 (UTC) From: Juri Linkov To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> Date: Mon, 02 Nov 2020 23:36:46 +0200 In-Reply-To: <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> ("Mattias =?iso-8859-1?Q?Engdeg=E5rd=22's?= message of "Sun, 1 Nov 2020 21:52:13 +0100") Message-ID: <87imanigpd.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Andreas Schwab , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Thus we would have 10 -> ?\n, 13 -> ?\r, 127 -> ?\d, 65 -> ?A, > 255 -> ?ÿ, but 31 -> 31, 129 -> 129, 4194303 -> 4194303. Hopefully, printing some characters as numbers will fix the currently broken test. > Since your original motivation was to print characters in pretty-printed > nested Lisp expressions, perhaps we should just define > print-integers-as-characters as a Boolean and skip the radix for the time > being? We could add a print radix control later on if desired. (That would > save us the hassle to deal with bignums, for that matter.) This was my intention - to start with something simple that does only what was needed (to print integers as characters), then extend it later when such a need arises as printing hex numbers. I added hex numbers only as a proof that the variable integer-output-format is extensible enough to support more formats in the future. But as you point out, this is achievable by adding another variable like print-integer-radix. PS: I notices inconsistency in these names: "integer" in print-integer-radix is singular, but "integers" in print-integers-as-characters is plural. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 02 18:03:44 2020 Received: (at 44155) by debbugs.gnu.org; 2 Nov 2020 23:03:44 +0000 Received: from localhost ([127.0.0.1]:42893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZirY-00088C-04 for submit@debbugs.gnu.org; Mon, 02 Nov 2020 18:03:44 -0500 Received: from mail1438c50.megamailservers.eu ([91.136.14.38]:58976 helo=mail263c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZirV-00087x-82 for 44155@debbugs.gnu.org; Mon, 02 Nov 2020 18:03:42 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604358214; bh=ovPZ1fNG+FJ1F8AuIpWTLoBfEPNTCToJDvklWoQt8Tg=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=a2MMAZeK4dc9+dCbRM5ednHFO9Do+JnTkyZJEUiI+c0CeaSomSdmjFblqLVX/g/W7 en0SglHIuvxwzFQES45z2WXyDnbMb+52TeuqK9EEFv3uRnoXAjYM5uPmqg7YeKpdqs G1x9/n9+n2zCRCdPn+BGFdv/tqg9GdG0Bd++TCCo= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail263c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A2N3VFX017476; Mon, 2 Nov 2020 23:03:33 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_CAF86D6E-F541-477D-8FF1-8AF29BF0F072" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters Date: Tue, 3 Nov 2020 00:03:31 +0100 In-Reply-To: <87imanigpd.fsf@mail.linkov.net> To: Juri Linkov References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F1B.5FA09046.0014, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=e6d4tph/ c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=ucMQw-l_AAAA:8 a=OXJBMAa00LakVAwSwSkA:9 a=QEXdDO2ut3YA:10 a=FjIXYbd6423xt65mSjwA:9 a=B2y7HmGcmWMA:10 a=xkTruGkd22MpkFU079mG:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 2 nov. 2020 kl. 22.36 skrev Juri Linkov : > >> Thus we would have 10 -> ?\n, 13 -> ?\r, 127 -> ?\d, 65 -> ?A, >> 255 -> ?ÿ, but 31 -> 31, 129 -> 129, 4194303 -> 4194303. > > Hopefull [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Andreas Schwab , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_CAF86D6E-F541-477D-8FF1-8AF29BF0F072 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 2 nov. 2020 kl. 22.36 skrev Juri Linkov : >=20 >> Thus we would have 10 -> ?\n, 13 -> ?\r, 127 -> ?\d, 65 -> ?A, >> 255 -> ?=C3=BF, but 31 -> 31, 129 -> 129, 4194303 -> 4194303. >=20 > Hopefully, printing some characters as numbers will fix > the currently broken test. It does! Here is a proposed patch. We could add a separate radix control = later if you like. One detail that I'm undecided about is whether to remove the more = obscure control escapes \f, \a, \v, \e and \d, on the grounds that they = are less likely to be used as actual characters and that users may = prefer to see them as numbers instead. C, and most languages inheriting = them from C, lack \e or \d; \f and \a are rare today, and \v is an = anachronism. > PS: I notices inconsistency in these names: "integer" in = print-integer-radix > is singular, but "integers" in print-integers-as-characters is plural. Actually, 'integer' in 'integer radix' plays the part of adjective! --Apple-Mail=_CAF86D6E-F541-477D-8FF1-8AF29BF0F072 Content-Disposition: attachment; filename=0001-Reduce-integer-output-format-to-print-integers-as-ch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Reduce-integer-output-format-to-print-integers-as-ch.patch" Content-Transfer-Encoding: quoted-printable =46rom=200dc27757cd53bca3e05c93f29ca96d0845a50ec2=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=202=20Nov=202020=2023:37:16=20+0100=0A= Subject:=20[PATCH]=20Reduce=20integer-output-format=20to=20= print-integers-as-characters=0A=0AThe=20variable=20now=20only=20controls=20= whether=20characters=20are=20printed,=20not=0Athe=20radix.=20=20Control=20= chars=20are=20printed=20in=20human-readable=20syntax=0Asuch=20as=20?\n=20= if=20available,=20as=20numbers=20otherwise=20(bug#44155).=0ADone=20in=20= collaboration=20with=20Juri=20Linkov.=0A=0A*=20src/print.c=20= (named_escape):=20New=20function.=0A(print_object):=20Change=20semantics=20= as=20described=20above.=0A(syms_of_print):=20Rename=20= integer-output-format.=20=20Update=20doc=20string.=0A*=20= doc/lispref/streams.texi=20(Output=20Variables):=0A*=20etc/NEWS:=0A*=20= test/src/print-tests.el=20(print-integers-as-characters):=0ARename=20and=20= update=20according=20to=20new=20semantics.=20=20The=20test=20now=20= passes.=0A---=0A=20doc/lispref/streams.texi=20|=2013=20++++----=0A=20= etc/NEWS=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2011=20= ++++---=0A=20src/print.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2065=20= ++++++++++++++++++++++++++--------------=0A=20test/src/print-tests.el=20=20= |=2034=20++++++++++-----------=0A=204=20files=20changed,=2071=20= insertions(+),=2052=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/streams.texi=20b/doc/lispref/streams.texi=0Aindex=20= f171f13779..4bc97e4c48=20100644=0A---=20a/doc/lispref/streams.texi=0A+++=20= b/doc/lispref/streams.texi=0A@@=20-903,10=20+903,11=20@@=20Output=20= Variables=0A=20you=20can=20use,=20see=20the=20variable's=20documentation=20= string.=0A=20@end=20defvar=0A=20=0A-@defvar=20integer-output-format=0A= -This=20variable=20specifies=20how=20to=20print=20integer=20numbers.=20=20= The=20default=20is=0A-@code{nil},=20meaning=20use=20the=20decimal=20= format.=20=20When=20bound=20to=20@code{t},=0A-print=20integers=20as=20= characters=20when=20an=20integer=20represents=20a=20character=0A= -(@pxref{Basic=20Char=20Syntax}).=20=20When=20bound=20to=20the=20number=20= @code{16},=0A-print=20non-negative=20integers=20in=20the=20hexadecimal=20= format.=0A+@defvar=20print-integers-as-characters=0A+When=20this=20= variable=20is=20non-@code{nil},=20integers=20that=20represent=0A= +printable=20characters=20or=20control=20characters=20with=20their=20own=20= escape=0A+syntax=20such=20as=20newline=20will=20be=20printed=20using=20= Lisp=20character=20syntax=0A+(@pxref{Basic=20Char=20Syntax}).=20=20Other=20= numbers=20are=20printed=20the=20usual=20way.=0A+For=20example,=20the=20= list=20@code{(4=2065=20-1=2010)}=20will=20be=20printed=20as=0A+@samp{(4=20= ?A=20-1=20?\n)}.=0A=20@end=20defvar=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20e11effc9e8..810d6794f2=20100644=0A---=20a/etc/NEWS=0A= +++=20b/etc/NEWS=0A@@=20-1689,12=20+1689,6=20@@=20ledit.el,=20lmenu.el,=20= lucid.el=20and=20old-whitespace.el.=0A=20=0C=0A=20*=20Lisp=20Changes=20= in=20Emacs=2028.1=0A=20=0A-**=20New=20variable=20'integer-output-format'=20= determines=20how=20to=20print=20integer=20values.=0A-When=20this=20= variable=20is=20bound=20to=20the=20value=20't',=20integers=20are=20= printed=20by=0A-printing=20functions=20as=20characters=20when=20an=20= integer=20represents=20a=20character.=0A-When=20bound=20to=20the=20= number=2016,=20non-negative=20integers=20are=20printed=20in=20the=0A= -hexadecimal=20format.=0A-=0A=20+++=0A=20**=20= 'define-globalized-minor-mode'=20now=20takes=20a=20':predicate'=20= parameter.=0A=20This=20can=20be=20used=20to=20control=20which=20major=20= modes=20the=20minor=20mode=20should=20be=0A@@=20-1887,6=20+1881,11=20@@=20= file=20can=20affect=20code=20in=20another.=20=20For=20details,=20see=20= the=20manual=20section=0A=20'replace-regexp-in-string',=20'catch',=20= 'throw',=20'error',=20'signal'=0A=20and=20'play-sound-file'.=0A=20=0A= ++++=0A+**=20New=20variable=20'print-integers-as-characters'=20modifies=20= integer=20printing.=0A+When=20this=20variable=20is=20non-nil,=20integers=20= representing=20characters=20are=0A+printed=20using=20Lisp=20character=20= syntax,=20such=20as=20'?*'=20for=2042.=0A+=0A=20=0C=0A=20*=20Changes=20= in=20Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0Adiff=20= --git=20a/src/print.c=20b/src/print.c=0Aindex=20fa65a3cb26..89efcb2006=20= 100644=0A---=20a/src/print.c=0A+++=20b/src/print.c=0A@@=20-1848,6=20= +1848,25=20@@=20print_vectorlike=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag,=0A=20=20=20return=20true;=0A=20}=0A=20= =0A+static=20char=0A+named_escape=20(int=20i)=0A+{=0A+=20=20switch=20(i)=0A= +=20=20=20=20{=0A+=20=20=20=20case=20'\a':=20return=20'a';=0A+=20=20=20=20= case=20'\b':=20return=20'b';=0A+=20=20=20=20case=20'\t':=20return=20't';=0A= +=20=20=20=20case=20'\n':=20return=20'n';=0A+=20=20=20=20case=20'\v':=20= return=20'v';=0A+=20=20=20=20case=20'\f':=20return=20'f';=0A+=20=20=20=20= case=20'\r':=20return=20'r';=0A+=20=20=20=20case=2027:=20=20=20return=20= 'e';=0A+=20=20=20=20case=20'=20':=20=20return=20's';=0A+=20=20=20=20case=20= 127:=20=20return=20'd';=0A+=20=20=20=20}=0A+=20=20return=200;=0A+}=0A+=0A= =20static=20void=0A=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag)=0A=20{=0A@@=20-1908,29=20+1927,31=20= @@=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20printcharfun,=20= bool=20escapeflag)=0A=20=20=20=20=20{=0A=20=20=20=20=20case_Lisp_Int:=0A=20= =20=20=20=20=20=20{=0A-=09int=20c;=0A-=09intmax_t=20i;=0A+=20=20=20=20=20= =20=20=20EMACS_INT=20i=20=3D=20XFIXNUM=20(obj);=0A+=20=20=20=20=20=20=20=20= char=20escaped_name;=0A=20=0A-=09if=20(EQ=20(Vinteger_output_format,=20= Qt)=20&&=20CHARACTERP=20(obj)=0A-=09=20=20=20=20&&=20(c=20=3D=20XFIXNUM=20= (obj)))=0A+=09if=20(print_integers_as_characters=20&&=20i=20>=3D=200=20= &&=20i=20<=3D=20MAX_UNICODE_CHAR=0A+=20=20=20=20=20=20=20=20=20=20=20=20= &&=20((escaped_name=20=3D=20named_escape=20(i))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20||=20(i=20>=3D=2032=20&&=20i=20<=3D=20127)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20>=3D=200xa0))=0A=20= =09=20=20{=0A=20=09=20=20=20=20printchar=20('?',=20printcharfun);=0A-=09=20= =20=20=20if=20(escapeflag=0A-=09=09&&=20(c=20=3D=3D=20';'=20||=20c=20=3D=3D= =20'('=20||=20c=20=3D=3D=20')'=20||=20c=20=3D=3D=20'{'=20||=20c=20=3D=3D=20= '}'=0A-=09=09=20=20=20=20||=20c=20=3D=3D=20'['=20||=20c=20=3D=3D=20']'=20= ||=20c=20=3D=3D=20'\"'=20||=20c=20=3D=3D=20'\''=20||=20c=20=3D=3D=20= '\\'))=0A+=20=20=20=20=20=20=20=20=20=20=20=20if=20(escaped_name)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20printchar=20('\\',=20printcharfun);=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20i=20=3D=20escaped_name;=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20else=20if=20= (escapeflag=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20&&=20(i=20=3D=3D=20';'=20||=20i=20=3D=3D=20'\"'=20||=20i=20=3D=3D=20= '\''=20||=20i=20=3D=3D=20'\\'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D=20'('=20||=20i=20=3D=3D=20= ')'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20||=20i=20=3D=3D=20'{'=20||=20i=20=3D=3D=20'}'=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D= =20'['=20||=20i=20=3D=3D=20']'))=0A=20=09=20=20=20=20=20=20printchar=20= ('\\',=20printcharfun);=0A-=09=20=20=20=20printchar=20(c,=20= printcharfun);=0A-=09=20=20}=0A-=09else=20if=20(INTEGERP=20= (Vinteger_output_format)=0A-=09=09=20&&=20integer_to_intmax=20= (Vinteger_output_format,=20&i)=0A-=09=09=20&&=20i=20=3D=3D=2016=20&&=20= !NILP=20(Fnatnump=20(obj)))=0A-=09=20=20{=0A-=09=20=20=20=20int=20len=20= =3D=20sprintf=20(buf,=20"#x%"pI"x",=20(EMACS_UINT)=20XFIXNUM=20(obj));=0A= -=09=20=20=20=20strout=20(buf,=20len,=20len,=20printcharfun);=0A+=09=20=20= =20=20printchar=20(i,=20printcharfun);=0A=20=09=20=20}=0A=20=09else=0A=20= =09=20=20{=0A-=09=20=20=20=20int=20len=20=3D=20sprintf=20(buf,=20= "%"pI"d",=20XFIXNUM=20(obj));=0A+=09=20=20=20=20int=20len=20=3D=20= sprintf=20(buf,=20"%"pI"d",=20i);=0A=20=09=20=20=20=20strout=20(buf,=20= len,=20len,=20printcharfun);=0A=20=09=20=20}=0A=20=20=20=20=20=20=20}=0A= @@=20-2270,12=20+2291,12=20@@=20syms_of_print=20(void)=0A=20that=20= represents=20the=20number=20without=20losing=20information.=20=20*/);=0A=20= =20=20Vfloat_output_format=20=3D=20Qnil;=0A=20=0A-=20=20DEFVAR_LISP=20= ("integer-output-format",=20Vinteger_output_format,=0A-=09=20=20=20=20=20= =20=20doc:=20/*=20The=20format=20used=20to=20print=20integers.=0A-When=20= t,=20print=20characters=20from=20integers=20that=20represent=20a=20= character.=0A-When=20a=20number=2016,=20print=20non-negative=20integers=20= in=20the=20hexadecimal=20format.=0A-Otherwise,=20by=20default=20print=20= integers=20in=20the=20decimal=20format.=20=20*/);=0A-=20=20= Vinteger_output_format=20=3D=20Qnil;=0A+=20=20DEFVAR_BOOL=20= ("print-integers-as-characters",=20print_integers_as_characters,=0A+=09=20= =20=20=20=20=20=20doc:=20/*=20Non-nil=20means=20integers=20are=20printed=20= using=20characters=20syntax.=0A+Only=20non-control=20characters,=20and=20= control=20characters=20with=20named=20escape=0A+sequences=20such=20as=20= newline,=20are=20printed=20this=20way.=20=20Other=20integers,=0A= +including=20those=20corresponding=20to=20raw=20bytes,=20are=20not=20= affected.=20=20*/);=0A+=20=20print_integers_as_characters=20=3D=20Qnil;=0A= =20=0A=20=20=20DEFVAR_LISP=20("print-length",=20Vprint_length,=0A=20=09=20= =20=20=20=20=20=20doc:=20/*=20Maximum=20length=20of=20list=20to=20print=20= before=20abbreviating.=0Adiff=20--git=20a/test/src/print-tests.el=20= b/test/src/print-tests.el=0Aindex=207b026b6b21..0053f3cac0=20100644=0A= ---=20a/test/src/print-tests.el=0A+++=20b/test/src/print-tests.el=0A@@=20= -383,25=20+383,23=20@@=20print-hash-table-test=0A=20=20=20=20=20=20=20= (let=20((print-length=201))=0A=20=20=20=20=20=20=20=20=20(format=20"%S"=20= h))))))=0A=20=0A-(print-tests--deftest=20print-integer-output-format=20= ()=0A+(print-tests--deftest=20print-integers-as-characters=20()=0A=20=20=20= ;;=20Bug#44155.=0A-=20=20(let=20((integer-output-format=20t)=0A-=20=20=20= =20=20=20=20=20(syms=20(list=20??=20?\;=20?\(=20?\)=20?\{=20?\}=20?\[=20= ?\]=20?\"=20?\'=20?\\=20?=C3=81)))=0A-=20=20=20=20(should=20(equal=20= (read=20(print-tests--prin1-to-string=20syms))=20syms))=0A-=20=20=20=20= (should=20(equal=20(print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=20= #'prin1-char=20syms=20"=20")=20")"))))=0A-=20=20(let=20= ((integer-output-format=20t)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20?\120=204194175=204194176=20(max-char)=20(1+=20= (max-char)))))=0A-=20=20=20=20(should=20(equal=20(read=20= (print-tests--prin1-to-string=20syms))=20syms)))=0A-=20=20(let=20= ((integer-output-format=2016)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20most-positive-fixnum=20(1+=20most-positive-fixnum))))=0A-=20= =20=20=20(should=20(equal=20(read=20(print-tests--prin1-to-string=20= syms))=20syms))=0A-=20=20=20=20(should=20(equal=20= (print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (lambda=20(i)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20(>=3D=20i=200)=20= (<=3D=20i=20most-positive-fixnum))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(format=20"#x%x"=20i)=20(format=20"%d"=20i)))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= syms=20"=20")=20")")))))=0A+=20=20(let*=20((print-integers-as-characters=20= t)=0A+=20=20=20=20=20=20=20=20=20(chars=20'(??=20?\;=20?\(=20?\)=20?\{=20= ?\}=20?\[=20?\]=20?\"=20?\'=20?\\=20?f=20?~=20?=C3=81=2032=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20?\n=20?\r=20?\t=20?\b=20?\f=20= ?\a=20?\v=20?\e=20?\d))=0A+=20=20=20=20=20=20=20=20=20(nums=20'(-1=20-65=20= 0=201=2031=20#x80=20#x9f=20#x110000=20#x3fff80=20#x3fffff))=0A+=20=20=20=20= =20=20=20=20=20(printed-chars=20(print-tests--prin1-to-string=20chars))=0A= +=20=20=20=20=20=20=20=20=20(printed-nums=20= (print-tests--prin1-to-string=20nums)))=0A+=20=20=20=20(should=20(equal=20= (read=20printed-chars)=20chars))=0A+=20=20=20=20(should=20(equal=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20printed-chars=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20(concat=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20"(??=20= ?\\;=20?\\(=20?\\)=20?\\{=20?\\}=20?\\[=20?\\]=20?\\\"=20?\\'=20?\\\\"=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20"=20?f=20?~=20?=C3=81=20?\\s=20= ?\\n=20?\\r=20?\\t=20?\\b=20?\\f=20?\\a=20?\\v=20?\\e=20?\\d)")))=0A+=20=20= =20=20(should=20(equal=20(read=20printed-nums)=20nums))=0A+=20=20=20=20= (should=20(equal=20printed-nums=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20"(-1=20-65=200=201=2031=20128=20159=201114112=20= 4194176=204194303)"))))=0A=20=0A=20(provide=20'print-tests)=0A=20;;;=20= print-tests.el=20ends=20here=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_CAF86D6E-F541-477D-8FF1-8AF29BF0F072-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 03 03:31:51 2020 Received: (at 44155) by debbugs.gnu.org; 3 Nov 2020 08:31:51 +0000 Received: from localhost ([127.0.0.1]:43282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZrjL-00075j-ER for submit@debbugs.gnu.org; Tue, 03 Nov 2020 03:31:51 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55973) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZrjJ-00075V-3W for 44155@debbugs.gnu.org; Tue, 03 Nov 2020 03:31:49 -0500 X-Originating-IP: 91.129.102.160 Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 7AE221C0019; Tue, 3 Nov 2020 08:31:40 +0000 (UTC) From: Juri Linkov To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= Subject: Re: bug#44155: Print integers as characters Organization: LINKOV.NET References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> Date: Tue, 03 Nov 2020 10:30:37 +0200 In-Reply-To: ("Mattias =?iso-8859-1?Q?Engdeg=E5rd=22's?= message of "Tue, 3 Nov 2020 00:03:31 +0100") Message-ID: <874km6q1ua.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, Andreas Schwab , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> Hopefully, printing some characters as numbers will fix >> the currently broken test. > > It does! Here is a proposed patch. We could add a separate radix control later if you like. Thanks, I like your patch, hope that Eli will like it too. > One detail that I'm undecided about is whether to remove the more obscure > control escapes \f, \a, \v, \e and \d, on the grounds that they are less > likely to be used as actual characters and that users may prefer to see > them as numbers instead. C, and most languages inheriting them from C, lack > \e or \d; \f and \a are rare today, and \v is an anachronism. I don't think that \f is rare, it's used as a page separator in many Emacs Lisp files. But it would be surprising to me to see 127 printed as ?\d, maybe because C lacks it. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 03 10:24:23 2020 Received: (at 44155) by debbugs.gnu.org; 3 Nov 2020 15:24:23 +0000 Received: from localhost ([127.0.0.1]:46073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZyAZ-0001LS-3q for submit@debbugs.gnu.org; Tue, 03 Nov 2020 10:24:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZyAX-0001LD-Se for 44155@debbugs.gnu.org; Tue, 03 Nov 2020 10:24:22 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45234) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyAQ-0006G8-G0; Tue, 03 Nov 2020 10:24:16 -0500 Received: from [176.228.60.248] (port=1804 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kZyAP-0000yq-UL; Tue, 03 Nov 2020 10:24:14 -0500 Date: Tue, 03 Nov 2020 17:24:05 +0200 Message-Id: <83ft5qcvl6.fsf@gnu.org> From: Eli Zaretskii To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= In-Reply-To: (message from Mattias =?utf-8?Q?Engdeg=C3=A5rd?= on Tue, 3 Nov 2020 00:03:31 +0100) Subject: Re: bug#44155: Print integers as characters References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias EngdegÃ¥rd > Date: Tue, 3 Nov 2020 00:03:31 +0100 > Cc: Eli Zaretskii , Andreas Schwab , > 44155@debbugs.gnu.org > > +@defvar print-integers-as-characters > +When this variable is non-@code{nil}, integers that represent > +printable characters or control characters with their own escape > +syntax such as newline will be printed using Lisp character syntax What is meant by "printable characters" here? One could think you mean [:print:], but that doesn't seem to be what then code does. > + DEFVAR_BOOL ("print-integers-as-characters", print_integers_as_characters, > + doc: /* Non-nil means integers are printed using characters syntax. > +Only non-control characters, and control characters with named escape > +sequences such as newline, are printed this way. Other integers, > +including those corresponding to raw bytes, are not affected. */); And here, what does "non-control characters" mean? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 03 13:47:26 2020 Received: (at 44155) by debbugs.gnu.org; 3 Nov 2020 18:47:26 +0000 Received: from localhost ([127.0.0.1]:46401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka1L3-0000FL-Qq for submit@debbugs.gnu.org; Tue, 03 Nov 2020 13:47:26 -0500 Received: from mail235c50.megamailservers.eu ([91.136.10.245]:32926 helo=mail56c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka1L1-0000FB-54 for 44155@debbugs.gnu.org; Tue, 03 Nov 2020 13:47:24 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604429241; bh=pBLrzG+EtqZeMGJtAeqLbyrYFlLDwcN6uwoEFayCUxk=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=sk8/FgMn2QTzwi935xWj2yHxgna7nsoIGDNXiZI16aO8/t3jKwSKSeqGjm6d726O7 SXQTIpnRJ2wmSrKzn5bTvWa3u/jZBV3TThV/LxFq7gfc/Qiah9Av6634Qs+wpdahFa MDqyRfnGJob+qn915LVZeTJvnbMizrBR+e+NXFk8= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail56c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A3IlI5I000897; Tue, 3 Nov 2020 18:47:20 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_617B665A-7A61-43DD-8AB1-4375417D29F4" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters Date: Tue, 3 Nov 2020 19:47:17 +0100 In-Reply-To: <83ft5qcvl6.fsf@gnu.org> To: Eli Zaretskii References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F1A.5FA1A5B9.0005, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=UqsdyN4B c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=19z2yNplLPHxvvvIWeQA:9 a=CjuIK1q_8ugA:10 a=8vRBGogvbazS6joDgeoA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 3 nov. 2020 kl. 16.24 skrev Eli Zaretskii : > What is meant by "printable characters" here? One could think you > mean [:print:], but that doesn't seem to be what then code does. Non-control characters (characters other than control characters), in this case. I wanted to keep things simple and not involve the Unicode database in the printer. Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_617B665A-7A61-43DD-8AB1-4375417D29F4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 3 nov. 2020 kl. 16.24 skrev Eli Zaretskii : > What is meant by "printable characters" here? One could think you > mean [:print:], but that doesn't seem to be what then code does. Non-control characters (characters other than control characters), in = this case. I wanted to keep things simple and not involve the Unicode = database in the printer. (For that matter, [:print:] is a regexp feature and doesn't really = define the meaning of 'printable', but your question was valid.) On the other hand, printing all non-controls using the ?X syntax is = maybe not ideal. Attached is a new patch that uses Unicode properties to = select only printable base characters. This patch also removes \a, \v, \e and \d from the characters printed as = escaped controls. --Apple-Mail=_617B665A-7A61-43DD-8AB1-4375417D29F4 Content-Disposition: attachment; filename=0001-Reduce-integer-output-format-to-print-integers-as-ch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Reduce-integer-output-format-to-print-integers-as-ch.patch" Content-Transfer-Encoding: quoted-printable =46rom=203da6d9055b0ae68fc7b3bbee52885113c8c30b6d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=202=20Nov=202020=2023:37:16=20+0100=0A= Subject:=20[PATCH]=20Reduce=20integer-output-format=20to=20= print-integers-as-characters=0A=0AThe=20variable=20now=20only=20controls=20= whether=20characters=20are=20printed,=20not=0Athe=20radix.=20=20Control=20= chars=20are=20printed=20in=20human-readable=20syntax=0Asuch=20as=20?\n=20= if=20available,=20as=20numbers=20otherwise=20(bug#44155).=0ADone=20in=20= collaboration=20with=20Juri=20Linkov.=0A=0A*=20src/character.c=20= (printable_base_p):=0A*=20src/print.c=20(named_escape):=20New=20= functions.=0A(print_object):=20Change=20semantics=20as=20described=20= above.=0A(syms_of_print):=20Rename=20integer-output-format.=20=20Update=20= doc=20string.=0A*=20doc/lispref/streams.texi=20(Output=20Variables):=0A*=20= etc/NEWS:=0A*=20test/src/print-tests.el=20= (print-integers-as-characters):=0ARename=20and=20update=20according=20to=20= new=20semantics.=20=20The=20test=20now=20passes.=0A---=0A=20= doc/lispref/streams.texi=20|=2013=20+++++----=0A=20etc/NEWS=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=2011=20++++---=0A=20= src/character.c=20=20=20=20=20=20=20=20=20=20|=2021=20++++++++++++++=0A=20= src/character.h=20=20=20=20=20=20=20=20=20=20|=20=201=20+=0A=20= src/print.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2063=20= ++++++++++++++++++++++++++--------------=0A=20test/src/print-tests.el=20=20= |=2039=20+++++++++++++------------=0A=206=20files=20changed,=2096=20= insertions(+),=2052=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/streams.texi=20b/doc/lispref/streams.texi=0Aindex=20= f171f13779..4bc97e4c48=20100644=0A---=20a/doc/lispref/streams.texi=0A+++=20= b/doc/lispref/streams.texi=0A@@=20-903,10=20+903,11=20@@=20Output=20= Variables=0A=20you=20can=20use,=20see=20the=20variable's=20documentation=20= string.=0A=20@end=20defvar=0A=20=0A-@defvar=20integer-output-format=0A= -This=20variable=20specifies=20how=20to=20print=20integer=20numbers.=20=20= The=20default=20is=0A-@code{nil},=20meaning=20use=20the=20decimal=20= format.=20=20When=20bound=20to=20@code{t},=0A-print=20integers=20as=20= characters=20when=20an=20integer=20represents=20a=20character=0A= -(@pxref{Basic=20Char=20Syntax}).=20=20When=20bound=20to=20the=20number=20= @code{16},=0A-print=20non-negative=20integers=20in=20the=20hexadecimal=20= format.=0A+@defvar=20print-integers-as-characters=0A+When=20this=20= variable=20is=20non-@code{nil},=20integers=20that=20represent=0A= +printable=20characters=20or=20control=20characters=20with=20their=20own=20= escape=0A+syntax=20such=20as=20newline=20will=20be=20printed=20using=20= Lisp=20character=20syntax=0A+(@pxref{Basic=20Char=20Syntax}).=20=20Other=20= numbers=20are=20printed=20the=20usual=20way.=0A+For=20example,=20the=20= list=20@code{(4=2065=20-1=2010)}=20will=20be=20printed=20as=0A+@samp{(4=20= ?A=20-1=20?\n)}.=0A=20@end=20defvar=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20e11effc9e8..384c64a91e=20100644=0A---=20a/etc/NEWS=0A= +++=20b/etc/NEWS=0A@@=20-1689,12=20+1689,6=20@@=20ledit.el,=20lmenu.el,=20= lucid.el=20and=20old-whitespace.el.=0A=20=0C=0A=20*=20Lisp=20Changes=20= in=20Emacs=2028.1=0A=20=0A-**=20New=20variable=20'integer-output-format'=20= determines=20how=20to=20print=20integer=20values.=0A-When=20this=20= variable=20is=20bound=20to=20the=20value=20't',=20integers=20are=20= printed=20by=0A-printing=20functions=20as=20characters=20when=20an=20= integer=20represents=20a=20character.=0A-When=20bound=20to=20the=20= number=2016,=20non-negative=20integers=20are=20printed=20in=20the=0A= -hexadecimal=20format.=0A-=0A=20+++=0A=20**=20= 'define-globalized-minor-mode'=20now=20takes=20a=20':predicate'=20= parameter.=0A=20This=20can=20be=20used=20to=20control=20which=20major=20= modes=20the=20minor=20mode=20should=20be=0A@@=20-1887,6=20+1881,11=20@@=20= file=20can=20affect=20code=20in=20another.=20=20For=20details,=20see=20= the=20manual=20section=0A=20'replace-regexp-in-string',=20'catch',=20= 'throw',=20'error',=20'signal'=0A=20and=20'play-sound-file'.=0A=20=0A= ++++=0A+**=20New=20variable=20'print-integers-as-characters'=20modifies=20= integer=20printing.=0A+When=20this=20variable=20is=20non-nil,=20= character=20syntax=20is=20used=20for=20printing=0A+numbers=20for=20which=20= this=20makes=20sense,=20such=20as=20'?*'=20for=2042.=0A+=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0A= diff=20--git=20a/src/character.c=20b/src/character.c=0Aindex=20= 5860f6a0c8..6d18e78f26=20100644=0A---=20a/src/character.c=0A+++=20= b/src/character.c=0A@@=20-982,6=20+982,27=20@@=20printablep=20(int=20c)=0A= =20=09=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20= unassigned=20*/=0A=20}=0A=20=0A+/*=20Return=20true=20if=20C=20is=20a=20= printable=20independent=20character.=20=20*/=0A+bool=0A+printable_base_p=20= (int=20c)=0A+{=0A+=20=20Lisp_Object=20category=20=3D=20CHAR_TABLE_REF=20= (Vunicode_category_table,=20c);=0A+=20=20if=20(!=20FIXNUMP=20(category))=0A= +=20=20=20=20return=20false;=0A+=20=20EMACS_INT=20gen_cat=20=3D=20= XFIXNUM=20(category);=0A+=0A+=20=20/*=20See=20UTS=20#18.=20=20*/=0A+=20=20= return=20(!(gen_cat=20=3D=3D=20UNICODE_CATEGORY_Mn=20=20=20=20=20=20=20= /*=20mark,=20nonspacing=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20= gen_cat=20=3D=3D=20UNICODE_CATEGORY_Mc=20=20=20=20/*=20mark,=20combining=20= */=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Me=20=20=20=20/*=20mark,=20enclosing=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zl=20=20= =20=20/*=20separator,=20line=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zp=20=20=20=20/*=20separator,=20= paragraph=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D= =20UNICODE_CATEGORY_Cc=20=20=20=20/*=20other,=20control=20*/=0A+=20=20=20= =20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cs=20= =20=20=20/*=20other,=20surrogate=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20= =20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cf=20=20=20=20/*=20other,=20= format=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Cn));=20/*=20other,=20unassigned=20*/=0A+}=0A+=0A=20/*=20= Return=20true=20if=20C=20is=20a=20horizontal=20whitespace=20character,=20= as=20defined=0A=20=20=20=20by=20= https://www.unicode.org/reports/tr18/tr18-19.html#blank.=20=20*/=0A=20= bool=0Adiff=20--git=20a/src/character.h=20b/src/character.h=0Aindex=20= af5023f77c..260c550108=20100644=0A---=20a/src/character.h=0A+++=20= b/src/character.h=0A@@=20-583,6=20+583,7=20@@=20char_surrogate_p=20(int=20= c)=0A=20extern=20bool=20graphicp=20(int);=0A=20extern=20bool=20= printablep=20(int);=0A=20extern=20bool=20blankp=20(int);=0A+extern=20= bool=20printable_base_p=20(int);=0A=20=0A=20/*=20Look=20up=20the=20= element=20in=20char=20table=20OBJ=20at=20index=20CH,=20and=20return=20it=20= as=0A=20=20=20=20an=20integer.=20=20If=20the=20element=20is=20not=20a=20= character,=20return=20CH=20itself.=20=20*/=0Adiff=20--git=20= a/src/print.c=20b/src/print.c=0Aindex=20fa65a3cb26..f7158dbac0=20100644=0A= ---=20a/src/print.c=0A+++=20b/src/print.c=0A@@=20-1848,6=20+1848,24=20@@=20= print_vectorlike=20(Lisp_Object=20obj,=20Lisp_Object=20printcharfun,=20= bool=20escapeflag,=0A=20=20=20return=20true;=0A=20}=0A=20=0A+static=20= char=0A+named_escape=20(int=20i)=0A+{=0A+=20=20switch=20(i)=0A+=20=20=20=20= {=0A+=20=20=20=20case=20'\b':=20return=20'b';=0A+=20=20=20=20case=20= '\t':=20return=20't';=0A+=20=20=20=20case=20'\n':=20return=20'n';=0A+=20=20= =20=20case=20'\f':=20return=20'f';=0A+=20=20=20=20case=20'\r':=20return=20= 'r';=0A+=20=20=20=20case=20'=20':=20=20return=20's';=0A+=20=20=20=20=20=20= /*=20\a,=20\v,=20\e=20and=20\d=20are=20excluded=20from=20printing=20as=20= escapes=20since=0A+=20=20=20=20=20=20=20=20=20they=20are=20somewhat=20= rare=20as=20characters=20and=20more=20likely=20to=20be=0A+=20=20=20=20=20= =20=20=20=20plain=20integers.=20*/=0A+=20=20=20=20}=0A+=20=20return=200;=0A= +}=0A+=0A=20static=20void=0A=20print_object=20(Lisp_Object=20obj,=20= Lisp_Object=20printcharfun,=20bool=20escapeflag)=0A=20{=0A@@=20-1908,29=20= +1926,30=20@@=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag)=0A=20=20=20=20=20{=0A=20=20=20=20=20= case_Lisp_Int:=0A=20=20=20=20=20=20=20{=0A-=09int=20c;=0A-=09intmax_t=20= i;=0A+=20=20=20=20=20=20=20=20EMACS_INT=20i=20=3D=20XFIXNUM=20(obj);=0A+=20= =20=20=20=20=20=20=20char=20escaped_name;=0A=20=0A-=09if=20(EQ=20= (Vinteger_output_format,=20Qt)=20&&=20CHARACTERP=20(obj)=0A-=09=20=20=20=20= &&=20(c=20=3D=20XFIXNUM=20(obj)))=0A+=09if=20= (print_integers_as_characters=20&&=20i=20>=3D=200=20&&=20i=20<=3D=20= MAX_UNICODE_CHAR=0A+=20=20=20=20=20=20=20=20=20=20=20=20&&=20= ((escaped_name=20=3D=20named_escape=20(i))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20||=20printable_base_p=20(i)))=0A=20=09=20=20{=0A=20=09= =20=20=20=20printchar=20('?',=20printcharfun);=0A-=09=20=20=20=20if=20= (escapeflag=0A-=09=09&&=20(c=20=3D=3D=20';'=20||=20c=20=3D=3D=20'('=20||=20= c=20=3D=3D=20')'=20||=20c=20=3D=3D=20'{'=20||=20c=20=3D=3D=20'}'=0A-=09=09= =20=20=20=20||=20c=20=3D=3D=20'['=20||=20c=20=3D=3D=20']'=20||=20c=20=3D=3D= =20'\"'=20||=20c=20=3D=3D=20'\''=20||=20c=20=3D=3D=20'\\'))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20if=20(escaped_name)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= printchar=20('\\',=20printcharfun);=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20i=20=3D=20escaped_name;=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20else=20if=20(escapeflag=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20(i=20= =3D=3D=20';'=20||=20i=20=3D=3D=20'\"'=20||=20i=20=3D=3D=20'\''=20||=20i=20= =3D=3D=20'\\'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20||=20i=20=3D=3D=20'('=20||=20i=20=3D=3D=20')'=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20= i=20=3D=3D=20'{'=20||=20i=20=3D=3D=20'}'=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D=20'['=20||=20= i=20=3D=3D=20']'))=0A=20=09=20=20=20=20=20=20printchar=20('\\',=20= printcharfun);=0A-=09=20=20=20=20printchar=20(c,=20printcharfun);=0A-=09=20= =20}=0A-=09else=20if=20(INTEGERP=20(Vinteger_output_format)=0A-=09=09=20= &&=20integer_to_intmax=20(Vinteger_output_format,=20&i)=0A-=09=09=20&&=20= i=20=3D=3D=2016=20&&=20!NILP=20(Fnatnump=20(obj)))=0A-=09=20=20{=0A-=09=20= =20=20=20int=20len=20=3D=20sprintf=20(buf,=20"#x%"pI"x",=20(EMACS_UINT)=20= XFIXNUM=20(obj));=0A-=09=20=20=20=20strout=20(buf,=20len,=20len,=20= printcharfun);=0A+=09=20=20=20=20printchar=20(i,=20printcharfun);=0A=20=09= =20=20}=0A=20=09else=0A=20=09=20=20{=0A-=09=20=20=20=20int=20len=20=3D=20= sprintf=20(buf,=20"%"pI"d",=20XFIXNUM=20(obj));=0A+=09=20=20=20=20int=20= len=20=3D=20sprintf=20(buf,=20"%"pI"d",=20i);=0A=20=09=20=20=20=20strout=20= (buf,=20len,=20len,=20printcharfun);=0A=20=09=20=20}=0A=20=20=20=20=20=20= =20}=0A@@=20-2270,12=20+2289,12=20@@=20syms_of_print=20(void)=0A=20that=20= represents=20the=20number=20without=20losing=20information.=20=20*/);=0A=20= =20=20Vfloat_output_format=20=3D=20Qnil;=0A=20=0A-=20=20DEFVAR_LISP=20= ("integer-output-format",=20Vinteger_output_format,=0A-=09=20=20=20=20=20= =20=20doc:=20/*=20The=20format=20used=20to=20print=20integers.=0A-When=20= t,=20print=20characters=20from=20integers=20that=20represent=20a=20= character.=0A-When=20a=20number=2016,=20print=20non-negative=20integers=20= in=20the=20hexadecimal=20format.=0A-Otherwise,=20by=20default=20print=20= integers=20in=20the=20decimal=20format.=20=20*/);=0A-=20=20= Vinteger_output_format=20=3D=20Qnil;=0A+=20=20DEFVAR_BOOL=20= ("print-integers-as-characters",=20print_integers_as_characters,=0A+=09=20= =20=20=20=20=20=20doc:=20/*=20Non-nil=20means=20integers=20are=20printed=20= using=20characters=20syntax.=0A+Only=20printable=20characters,=20and=20= control=20characters=20with=20named=20escape=0A+sequences=20such=20as=20= newline,=20are=20printed=20this=20way.=20=20Other=20integers,=0A= +including=20those=20corresponding=20to=20raw=20bytes,=20are=20not=20= affected.=20=20*/);=0A+=20=20print_integers_as_characters=20=3D=20Qnil;=0A= =20=0A=20=20=20DEFVAR_LISP=20("print-length",=20Vprint_length,=0A=20=09=20= =20=20=20=20=20=20doc:=20/*=20Maximum=20length=20of=20list=20to=20print=20= before=20abbreviating.=0Adiff=20--git=20a/test/src/print-tests.el=20= b/test/src/print-tests.el=0Aindex=207b026b6b21..05b1e4e6e4=20100644=0A= ---=20a/test/src/print-tests.el=0A+++=20b/test/src/print-tests.el=0A@@=20= -383,25=20+383,28=20@@=20print-hash-table-test=0A=20=20=20=20=20=20=20= (let=20((print-length=201))=0A=20=20=20=20=20=20=20=20=20(format=20"%S"=20= h))))))=0A=20=0A-(print-tests--deftest=20print-integer-output-format=20= ()=0A+(print-tests--deftest=20print-integers-as-characters=20()=0A=20=20=20= ;;=20Bug#44155.=0A-=20=20(let=20((integer-output-format=20t)=0A-=20=20=20= =20=20=20=20=20(syms=20(list=20??=20?\;=20?\(=20?\)=20?\{=20?\}=20?\[=20= ?\]=20?\"=20?\'=20?\\=20?=C3=81)))=0A-=20=20=20=20(should=20(equal=20= (read=20(print-tests--prin1-to-string=20syms))=20syms))=0A-=20=20=20=20= (should=20(equal=20(print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=20= #'prin1-char=20syms=20"=20")=20")"))))=0A-=20=20(let=20= ((integer-output-format=20t)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20?\120=204194175=204194176=20(max-char)=20(1+=20= (max-char)))))=0A-=20=20=20=20(should=20(equal=20(read=20= (print-tests--prin1-to-string=20syms))=20syms)))=0A-=20=20(let=20= ((integer-output-format=2016)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20most-positive-fixnum=20(1+=20most-positive-fixnum))))=0A-=20= =20=20=20(should=20(equal=20(read=20(print-tests--prin1-to-string=20= syms))=20syms))=0A-=20=20=20=20(should=20(equal=20= (print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (lambda=20(i)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20(>=3D=20i=200)=20= (<=3D=20i=20most-positive-fixnum))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(format=20"#x%x"=20i)=20(format=20"%d"=20i)))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= syms=20"=20")=20")")))))=0A+=20=20(let*=20((print-integers-as-characters=20= t)=0A+=20=20=20=20=20=20=20=20=20(chars=20'(??=20?\;=20?\(=20?\)=20?\{=20= ?\}=20?\[=20?\]=20?\"=20?\'=20?\\=20?f=20?~=20?=C3=81=2032=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20?\n=20?\r=20?\t=20?\b=20?\f=20= ?\a=20?\v=20?\e=20?\d))=0A+=20=20=20=20=20=20=20=20=20(nums=20'(-1=20-65=20= 0=201=2031=20#x80=20#x9f=20#x110000=20#x3fff80=20#x3fffff))=0A+=20=20=20=20= =20=20=20=20=20(nonprints=20'(#xd800=20#xdfff=20#x030a=20#xffff=20= #x200c))=0A+=20=20=20=20=20=20=20=20=20(printed-chars=20= (print-tests--prin1-to-string=20chars))=0A+=20=20=20=20=20=20=20=20=20= (printed-nums=20(print-tests--prin1-to-string=20nums))=0A+=20=20=20=20=20= =20=20=20=20(printed-nonprints=20(print-tests--prin1-to-string=20= nonprints)))=0A+=20=20=20=20(should=20(equal=20(read=20printed-chars)=20= chars))=0A+=20=20=20=20(should=20(equal=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20printed-chars=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20"(??=20?\\;=20?\\(=20?\\)=20= ?\\{=20?\\}=20?\\[=20?\\]=20?\\\"=20?\\'=20?\\\\"=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"=20?f=20?~=20?=C3=81=20?\\s=20?\\n=20?\\r=20?\\t=20= ?\\b=20?\\f=207=2011=2027=20127)")))=0A+=20=20=20=20(should=20(equal=20= (read=20printed-nums)=20nums))=0A+=20=20=20=20(should=20(equal=20= printed-nums=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= "(-1=20-65=200=201=2031=20128=20159=201114112=204194176=204194303)"))=0A= +=20=20=20=20(should=20(equal=20(read=20printed-nonprints)=20nonprints))=0A= +=20=20=20=20(should=20(equal=20printed-nonprints=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20"(55296=2057343=20778=2065535=20= 8204)"))))=0A=20=0A=20(provide=20'print-tests)=0A=20;;;=20print-tests.el=20= ends=20here=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_617B665A-7A61-43DD-8AB1-4375417D29F4-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 03 14:36:42 2020 Received: (at 44155) by debbugs.gnu.org; 3 Nov 2020 19:36:42 +0000 Received: from localhost ([127.0.0.1]:46493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka26j-0003fv-OB for submit@debbugs.gnu.org; Tue, 03 Nov 2020 14:36:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka26i-0003fj-5p for 44155@debbugs.gnu.org; Tue, 03 Nov 2020 14:36:40 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50359) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka26c-0007il-6I; Tue, 03 Nov 2020 14:36:34 -0500 Received: from [176.228.60.248] (port=1849 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ka26a-00006S-M2; Tue, 03 Nov 2020 14:36:33 -0500 Date: Tue, 03 Nov 2020 21:36:24 +0200 Message-Id: <83y2jib5c7.fsf@gnu.org> From: Eli Zaretskii To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= In-Reply-To: <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> (message from Mattias =?utf-8?Q?Engdeg=C3=A5rd?= on Tue, 3 Nov 2020 19:47:17 +0100) Subject: Re: bug#44155: Print integers as characters References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias EngdegÃ¥rd > Date: Tue, 3 Nov 2020 19:47:17 +0100 > Cc: juri@linkov.net, schwab@suse.de, 44155@debbugs.gnu.org > > > What is meant by "printable characters" here? One could think you > > mean [:print:], but that doesn't seem to be what then code does. > > Non-control characters (characters other than control characters), in this case. I wanted to keep things simple and not involve the Unicode database in the printer. > > (For that matter, [:print:] is a regexp feature and doesn't really define the meaning of 'printable', but your question was valid.) > > On the other hand, printing all non-controls using the ?X syntax is maybe not ideal. Attached is a new patch that uses Unicode properties to select only printable base characters. Thanks, but my main question is still not answered. I asked it from the POV of documentation: we should provide a more specific description of which characters will be printed as characters, so that users are not surprised. The text in NEWS still says "printable characters" without defining that term, and so does the doc string of print-integers-as-characters. And now there's another question, which is what caused you to filter characters like you did? E.g., what's wrong with combining classes? why not simply use graphicp? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 04 06:03:42 2020 Received: (at 44155) by debbugs.gnu.org; 4 Nov 2020 11:03:42 +0000 Received: from localhost ([127.0.0.1]:47674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaGZp-0001yR-Vh for submit@debbugs.gnu.org; Wed, 04 Nov 2020 06:03:42 -0500 Received: from mail74c50.megamailservers.eu ([91.136.10.84]:44326 helo=mail92c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaGZm-0001yG-1x for 44155@debbugs.gnu.org; Wed, 04 Nov 2020 06:03:40 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604487816; bh=kQpKhPDnPDUnLcLyyLSO8bhg9RbVYX9Kjl6kUtIdJj0=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=JNecNpaMAmBp1B+Oc/PdeIIVooxPA4pEPyS31vLmIEx97rLlAxxEaU/7UktA+ro1t JrEnNlpcMKGnbCekLjUlq6HzVL4RbAQrW6THkaeWAGLTWOgu4L3fJx2xKOIk5Jp82W edi5M3HUWuWqv8VAA9/5dN2PSEKUfjvwaJOmHmJw= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail92c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A4B3X8e002890; Wed, 4 Nov 2020 11:03:34 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_9FE844B9-FF7C-49E0-8210-7A8284BAFAD0" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters Date: Wed, 4 Nov 2020 12:03:32 +0100 In-Reply-To: <83y2jib5c7.fsf@gnu.org> To: Eli Zaretskii References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> <83y2jib5c7.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F1A.5FA28A87.00D4, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=aY8fYigt c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=8G6n9TNXTOqzS8r2epwA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=CjuIK1q_8ugA:10 a=8vRBGogvbazS6joDgeoA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 3 nov. 2020 kl. 20.36 skrev Eli Zaretskii : > Thanks, but my main question is still not answered. I asked it from > the POV of documentation: we should provide a more specific > description of which characters will be printed as characters, so [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_9FE844B9-FF7C-49E0-8210-7A8284BAFAD0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 3 nov. 2020 kl. 20.36 skrev Eli Zaretskii : > Thanks, but my main question is still not answered. I asked it from > the POV of documentation: we should provide a more specific > description of which characters will be printed as characters, so that > users are not surprised. The text in NEWS still says "printable > characters" without defining that term, and so does the doc string of > print-integers-as-characters. 'Printable' was used informally, not in an exact technical meaning. = Intuitively, it should be the set of characters that make sense to print = using the '?X' syntax. I initially thought that 'graphic' was too = technical but it is more precise. 'Independently printable graphic = character' is descriptive but a mouthful; perhaps 'independent graphic = char' would do? > And now there's another question, which is what caused you to filter > characters like you did? E.g., what's wrong with combining classes? > why not simply use graphicp? For the ?X syntax to make sense, X must be visible; thus controls are = out, and so are formatting chars (language tags etc). Spaces should = probably have been excluded as well since it's typically not possible to = see what kind of space follows the '?' (SPC is explicitly rendered as = ?\s). Furthermore, X must be independent since it isn't a grapheme cluster but = a single code point. Therefore combining chars cannot be included as = they would attach to the '?'. 'graphicp' cannot be used because it includes combining, enclosing and = nonspacing marks (M) and formats (Cf); otherwise it's fine. While we could put the exact list of excluded general categories in the = documentation, it is not very important because the selection only = matters for usability and aesthetics, not (realistically) for code = behaviour. The attached patch excludes spaces (Zs) and revises the terminology. --Apple-Mail=_9FE844B9-FF7C-49E0-8210-7A8284BAFAD0 Content-Disposition: attachment; filename=0001-Reduce-integer-output-format-to-print-integers-as-ch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Reduce-integer-output-format-to-print-integers-as-ch.patch" Content-Transfer-Encoding: quoted-printable =46rom=20fd24ef7e7b71308ff29b8d1b2f7be64254469521=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=202=20Nov=202020=2023:37:16=20+0100=0A= Subject:=20[PATCH]=20Reduce=20integer-output-format=20to=20= print-integers-as-characters=0A=0AThe=20variable=20now=20only=20controls=20= whether=20characters=20are=20printed,=20not=0Athe=20radix.=20=20Control=20= chars=20are=20printed=20in=20human-readable=20syntax=0Aonly=20when=20= special=20escapes=20such=20as=20?\n=20are=20available.=20=20Spaces,=0A= formatting=20and=20combining=20chars=20are=20excluded=20(bug#44155).=0A= Done=20in=20collaboration=20with=20Juri=20Linkov.=0A=0A*=20= src/character.c=20(graphic_base_p):=0A*=20src/print.c=20(named_escape):=20= New=20functions.=0A(print_object):=20Change=20semantics=20as=20described=20= above.=0A(syms_of_print):=20Rename=20integer-output-format.=20=20Update=20= doc=20string.=0A*=20doc/lispref/streams.texi=20(Output=20Variables):=0A*=20= etc/NEWS:=0A*=20test/src/print-tests.el=20= (print-integers-as-characters):=0ARename=20and=20update=20according=20to=20= new=20semantics.=20=20The=20test=20now=20passes.=0A---=0A=20= doc/lispref/streams.texi=20|=2013=20++++----=0A=20etc/NEWS=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=2011=20++++---=0A=20= src/character.c=20=20=20=20=20=20=20=20=20=20|=2021=20+++++++++++++=0A=20= src/character.h=20=20=20=20=20=20=20=20=20=20|=20=201=20+=0A=20= src/print.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2064=20= ++++++++++++++++++++++++++--------------=0A=20test/src/print-tests.el=20=20= |=2039=20+++++++++++++-----------=0A=206=20files=20changed,=2097=20= insertions(+),=2052=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/streams.texi=20b/doc/lispref/streams.texi=0Aindex=20= f171f13779..799d35b070=20100644=0A---=20a/doc/lispref/streams.texi=0A+++=20= b/doc/lispref/streams.texi=0A@@=20-903,10=20+903,11=20@@=20Output=20= Variables=0A=20you=20can=20use,=20see=20the=20variable's=20documentation=20= string.=0A=20@end=20defvar=0A=20=0A-@defvar=20integer-output-format=0A= -This=20variable=20specifies=20how=20to=20print=20integer=20numbers.=20=20= The=20default=20is=0A-@code{nil},=20meaning=20use=20the=20decimal=20= format.=20=20When=20bound=20to=20@code{t},=0A-print=20integers=20as=20= characters=20when=20an=20integer=20represents=20a=20character=0A= -(@pxref{Basic=20Char=20Syntax}).=20=20When=20bound=20to=20the=20number=20= @code{16},=0A-print=20non-negative=20integers=20in=20the=20hexadecimal=20= format.=0A+@defvar=20print-integers-as-characters=0A+When=20this=20= variable=20is=20non-@code{nil},=20integers=20that=20represent=0A= +independent=20graphic=20characters=20or=20control=20characters=20with=20= their=20own=0A+escape=20syntax=20such=20as=20newline=20will=20be=20= printed=20using=20Lisp=20character=0A+syntax=20(@pxref{Basic=20Char=20= Syntax}).=20=20Other=20numbers=20are=20printed=20the=0A+usual=20way.=20=20= For=20example,=20the=20list=20@code{(4=2065=20-1=2010)}=20will=20be=20= printed=0A+as=20@samp{(4=20?A=20-1=20?\n)}.=0A=20@end=20defvar=0Adiff=20= --git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=20e11effc9e8..384c64a91e=20= 100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-1689,12=20+1689,6=20= @@=20ledit.el,=20lmenu.el,=20lucid.el=20and=20old-whitespace.el.=0A=20=0C= =0A=20*=20Lisp=20Changes=20in=20Emacs=2028.1=0A=20=0A-**=20New=20= variable=20'integer-output-format'=20determines=20how=20to=20print=20= integer=20values.=0A-When=20this=20variable=20is=20bound=20to=20the=20= value=20't',=20integers=20are=20printed=20by=0A-printing=20functions=20= as=20characters=20when=20an=20integer=20represents=20a=20character.=0A= -When=20bound=20to=20the=20number=2016,=20non-negative=20integers=20are=20= printed=20in=20the=0A-hexadecimal=20format.=0A-=0A=20+++=0A=20**=20= 'define-globalized-minor-mode'=20now=20takes=20a=20':predicate'=20= parameter.=0A=20This=20can=20be=20used=20to=20control=20which=20major=20= modes=20the=20minor=20mode=20should=20be=0A@@=20-1887,6=20+1881,11=20@@=20= file=20can=20affect=20code=20in=20another.=20=20For=20details,=20see=20= the=20manual=20section=0A=20'replace-regexp-in-string',=20'catch',=20= 'throw',=20'error',=20'signal'=0A=20and=20'play-sound-file'.=0A=20=0A= ++++=0A+**=20New=20variable=20'print-integers-as-characters'=20modifies=20= integer=20printing.=0A+When=20this=20variable=20is=20non-nil,=20= character=20syntax=20is=20used=20for=20printing=0A+numbers=20for=20which=20= this=20makes=20sense,=20such=20as=20'?*'=20for=2042.=0A+=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0A= diff=20--git=20a/src/character.c=20b/src/character.c=0Aindex=20= 5860f6a0c8..00b73293a3=20100644=0A---=20a/src/character.c=0A+++=20= b/src/character.c=0A@@=20-982,6=20+982,27=20@@=20printablep=20(int=20c)=0A= =20=09=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20= unassigned=20*/=0A=20}=0A=20=0A+/*=20Return=20true=20if=20C=20is=20= graphic=20character=20that=20can=20be=20printed=20independently.=20=20*/=0A= +bool=0A+graphic_base_p=20(int=20c)=0A+{=0A+=20=20Lisp_Object=20category=20= =3D=20CHAR_TABLE_REF=20(Vunicode_category_table,=20c);=0A+=20=20if=20(!=20= FIXNUMP=20(category))=0A+=20=20=20=20return=20false;=0A+=20=20EMACS_INT=20= gen_cat=20=3D=20XFIXNUM=20(category);=0A+=0A+=20=20return=20(!(gen_cat=20= =3D=3D=20UNICODE_CATEGORY_Mn=20=20=20=20=20=20=20/*=20mark,=20nonspacing=20= */=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Mc=20=20=20=20/*=20mark,=20combining=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Me=20=20= =20=20/*=20mark,=20enclosing=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zs=20=20=20=20/*=20separator,=20= space=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Zl=20=20=20=20/*=20separator,=20line=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zp=20=20= =20=20/*=20separator,=20paragraph=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20= =20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cc=20=20=20=20/*=20other,=20= control=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Cs=20=20=20=20/*=20other,=20surrogate=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cf=20=20= =20=20/*=20other,=20format=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20other,=20= unassigned=20*/=0A+}=0A+=0A=20/*=20Return=20true=20if=20C=20is=20a=20= horizontal=20whitespace=20character,=20as=20defined=0A=20=20=20=20by=20= https://www.unicode.org/reports/tr18/tr18-19.html#blank.=20=20*/=0A=20= bool=0Adiff=20--git=20a/src/character.h=20b/src/character.h=0Aindex=20= af5023f77c..cbf43097ae=20100644=0A---=20a/src/character.h=0A+++=20= b/src/character.h=0A@@=20-583,6=20+583,7=20@@=20char_surrogate_p=20(int=20= c)=0A=20extern=20bool=20graphicp=20(int);=0A=20extern=20bool=20= printablep=20(int);=0A=20extern=20bool=20blankp=20(int);=0A+extern=20= bool=20graphic_base_p=20(int);=0A=20=0A=20/*=20Look=20up=20the=20element=20= in=20char=20table=20OBJ=20at=20index=20CH,=20and=20return=20it=20as=0A=20= =20=20=20an=20integer.=20=20If=20the=20element=20is=20not=20a=20= character,=20return=20CH=20itself.=20=20*/=0Adiff=20--git=20= a/src/print.c=20b/src/print.c=0Aindex=20fa65a3cb26..f2e2dd131d=20100644=0A= ---=20a/src/print.c=0A+++=20b/src/print.c=0A@@=20-1848,6=20+1848,24=20@@=20= print_vectorlike=20(Lisp_Object=20obj,=20Lisp_Object=20printcharfun,=20= bool=20escapeflag,=0A=20=20=20return=20true;=0A=20}=0A=20=0A+static=20= char=0A+named_escape=20(int=20i)=0A+{=0A+=20=20switch=20(i)=0A+=20=20=20=20= {=0A+=20=20=20=20case=20'\b':=20return=20'b';=0A+=20=20=20=20case=20= '\t':=20return=20't';=0A+=20=20=20=20case=20'\n':=20return=20'n';=0A+=20=20= =20=20case=20'\f':=20return=20'f';=0A+=20=20=20=20case=20'\r':=20return=20= 'r';=0A+=20=20=20=20case=20'=20':=20=20return=20's';=0A+=20=20=20=20=20=20= /*=20\a,=20\v,=20\e=20and=20\d=20are=20excluded=20from=20printing=20as=20= escapes=20since=0A+=20=20=20=20=20=20=20=20=20they=20are=20somewhat=20= rare=20as=20characters=20and=20more=20likely=20to=20be=0A+=20=20=20=20=20= =20=20=20=20plain=20integers.=20*/=0A+=20=20=20=20}=0A+=20=20return=200;=0A= +}=0A+=0A=20static=20void=0A=20print_object=20(Lisp_Object=20obj,=20= Lisp_Object=20printcharfun,=20bool=20escapeflag)=0A=20{=0A@@=20-1908,29=20= +1926,30=20@@=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag)=0A=20=20=20=20=20{=0A=20=20=20=20=20= case_Lisp_Int:=0A=20=20=20=20=20=20=20{=0A-=09int=20c;=0A-=09intmax_t=20= i;=0A+=20=20=20=20=20=20=20=20EMACS_INT=20i=20=3D=20XFIXNUM=20(obj);=0A+=20= =20=20=20=20=20=20=20char=20escaped_name;=0A=20=0A-=09if=20(EQ=20= (Vinteger_output_format,=20Qt)=20&&=20CHARACTERP=20(obj)=0A-=09=20=20=20=20= &&=20(c=20=3D=20XFIXNUM=20(obj)))=0A+=09if=20= (print_integers_as_characters=20&&=20i=20>=3D=200=20&&=20i=20<=3D=20= MAX_UNICODE_CHAR=0A+=20=20=20=20=20=20=20=20=20=20=20=20&&=20= ((escaped_name=20=3D=20named_escape=20(i))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20||=20graphic_base_p=20(i)))=0A=20=09=20=20{=0A=20=09= =20=20=20=20printchar=20('?',=20printcharfun);=0A-=09=20=20=20=20if=20= (escapeflag=0A-=09=09&&=20(c=20=3D=3D=20';'=20||=20c=20=3D=3D=20'('=20||=20= c=20=3D=3D=20')'=20||=20c=20=3D=3D=20'{'=20||=20c=20=3D=3D=20'}'=0A-=09=09= =20=20=20=20||=20c=20=3D=3D=20'['=20||=20c=20=3D=3D=20']'=20||=20c=20=3D=3D= =20'\"'=20||=20c=20=3D=3D=20'\''=20||=20c=20=3D=3D=20'\\'))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20if=20(escaped_name)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= printchar=20('\\',=20printcharfun);=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20i=20=3D=20escaped_name;=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20else=20if=20(escapeflag=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20(i=20= =3D=3D=20';'=20||=20i=20=3D=3D=20'\"'=20||=20i=20=3D=3D=20'\''=20||=20i=20= =3D=3D=20'\\'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20||=20i=20=3D=3D=20'('=20||=20i=20=3D=3D=20')'=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20= i=20=3D=3D=20'{'=20||=20i=20=3D=3D=20'}'=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D=20'['=20||=20= i=20=3D=3D=20']'))=0A=20=09=20=20=20=20=20=20printchar=20('\\',=20= printcharfun);=0A-=09=20=20=20=20printchar=20(c,=20printcharfun);=0A-=09=20= =20}=0A-=09else=20if=20(INTEGERP=20(Vinteger_output_format)=0A-=09=09=20= &&=20integer_to_intmax=20(Vinteger_output_format,=20&i)=0A-=09=09=20&&=20= i=20=3D=3D=2016=20&&=20!NILP=20(Fnatnump=20(obj)))=0A-=09=20=20{=0A-=09=20= =20=20=20int=20len=20=3D=20sprintf=20(buf,=20"#x%"pI"x",=20(EMACS_UINT)=20= XFIXNUM=20(obj));=0A-=09=20=20=20=20strout=20(buf,=20len,=20len,=20= printcharfun);=0A+=09=20=20=20=20printchar=20(i,=20printcharfun);=0A=20=09= =20=20}=0A=20=09else=0A=20=09=20=20{=0A-=09=20=20=20=20int=20len=20=3D=20= sprintf=20(buf,=20"%"pI"d",=20XFIXNUM=20(obj));=0A+=09=20=20=20=20int=20= len=20=3D=20sprintf=20(buf,=20"%"pI"d",=20i);=0A=20=09=20=20=20=20strout=20= (buf,=20len,=20len,=20printcharfun);=0A=20=09=20=20}=0A=20=20=20=20=20=20= =20}=0A@@=20-2270,12=20+2289,13=20@@=20syms_of_print=20(void)=0A=20that=20= represents=20the=20number=20without=20losing=20information.=20=20*/);=0A=20= =20=20Vfloat_output_format=20=3D=20Qnil;=0A=20=0A-=20=20DEFVAR_LISP=20= ("integer-output-format",=20Vinteger_output_format,=0A-=09=20=20=20=20=20= =20=20doc:=20/*=20The=20format=20used=20to=20print=20integers.=0A-When=20= t,=20print=20characters=20from=20integers=20that=20represent=20a=20= character.=0A-When=20a=20number=2016,=20print=20non-negative=20integers=20= in=20the=20hexadecimal=20format.=0A-Otherwise,=20by=20default=20print=20= integers=20in=20the=20decimal=20format.=20=20*/);=0A-=20=20= Vinteger_output_format=20=3D=20Qnil;=0A+=20=20DEFVAR_BOOL=20= ("print-integers-as-characters",=20print_integers_as_characters,=0A+=09=20= =20=20=20=20=20=20doc:=20/*=20Non-nil=20means=20integers=20are=20printed=20= using=20characters=20syntax.=0A+Only=20independent=20graphic=20= characters,=20and=20control=20characters=20with=20named=0A+escape=20= sequences=20such=20as=20newline,=20are=20printed=20this=20way.=20=20= Other=0A+integers,=20including=20those=20corresponding=20to=20raw=20= bytes,=20are=20printed=0A+affected.=20=20*/);=0A+=20=20= print_integers_as_characters=20=3D=20Qnil;=0A=20=0A=20=20=20DEFVAR_LISP=20= ("print-length",=20Vprint_length,=0A=20=09=20=20=20=20=20=20=20doc:=20/*=20= Maximum=20length=20of=20list=20to=20print=20before=20abbreviating.=0A= diff=20--git=20a/test/src/print-tests.el=20b/test/src/print-tests.el=0A= index=207b026b6b21..202555adb3=20100644=0A---=20= a/test/src/print-tests.el=0A+++=20b/test/src/print-tests.el=0A@@=20= -383,25=20+383,28=20@@=20print-hash-table-test=0A=20=20=20=20=20=20=20= (let=20((print-length=201))=0A=20=20=20=20=20=20=20=20=20(format=20"%S"=20= h))))))=0A=20=0A-(print-tests--deftest=20print-integer-output-format=20= ()=0A+(print-tests--deftest=20print-integers-as-characters=20()=0A=20=20=20= ;;=20Bug#44155.=0A-=20=20(let=20((integer-output-format=20t)=0A-=20=20=20= =20=20=20=20=20(syms=20(list=20??=20?\;=20?\(=20?\)=20?\{=20?\}=20?\[=20= ?\]=20?\"=20?\'=20?\\=20?=C3=81)))=0A-=20=20=20=20(should=20(equal=20= (read=20(print-tests--prin1-to-string=20syms))=20syms))=0A-=20=20=20=20= (should=20(equal=20(print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=20= #'prin1-char=20syms=20"=20")=20")"))))=0A-=20=20(let=20= ((integer-output-format=20t)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20?\120=204194175=204194176=20(max-char)=20(1+=20= (max-char)))))=0A-=20=20=20=20(should=20(equal=20(read=20= (print-tests--prin1-to-string=20syms))=20syms)))=0A-=20=20(let=20= ((integer-output-format=2016)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20most-positive-fixnum=20(1+=20most-positive-fixnum))))=0A-=20= =20=20=20(should=20(equal=20(read=20(print-tests--prin1-to-string=20= syms))=20syms))=0A-=20=20=20=20(should=20(equal=20= (print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (lambda=20(i)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20(>=3D=20i=200)=20= (<=3D=20i=20most-positive-fixnum))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(format=20"#x%x"=20i)=20(format=20"%d"=20i)))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= syms=20"=20")=20")")))))=0A+=20=20(let*=20((print-integers-as-characters=20= t)=0A+=20=20=20=20=20=20=20=20=20(chars=20'(??=20?\;=20?\(=20?\)=20?\{=20= ?\}=20?\[=20?\]=20?\"=20?\'=20?\\=20?f=20?~=20?=C3=81=2032=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20?\n=20?\r=20?\t=20?\b=20?\f=20= ?\a=20?\v=20?\e=20?\d))=0A+=20=20=20=20=20=20=20=20=20(nums=20'(-1=20-65=20= 0=201=2031=20#x80=20#x9f=20#x110000=20#x3fff80=20#x3fffff))=0A+=20=20=20=20= =20=20=20=20=20(nonprints=20'(#xd800=20#xdfff=20#x030a=20#xffff=20#x2002=20= #x200c))=0A+=20=20=20=20=20=20=20=20=20(printed-chars=20= (print-tests--prin1-to-string=20chars))=0A+=20=20=20=20=20=20=20=20=20= (printed-nums=20(print-tests--prin1-to-string=20nums))=0A+=20=20=20=20=20= =20=20=20=20(printed-nonprints=20(print-tests--prin1-to-string=20= nonprints)))=0A+=20=20=20=20(should=20(equal=20(read=20printed-chars)=20= chars))=0A+=20=20=20=20(should=20(equal=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20printed-chars=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20"(??=20?\\;=20?\\(=20?\\)=20= ?\\{=20?\\}=20?\\[=20?\\]=20?\\\"=20?\\'=20?\\\\"=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"=20?f=20?~=20?=C3=81=20?\\s=20?\\n=20?\\r=20?\\t=20= ?\\b=20?\\f=207=2011=2027=20127)")))=0A+=20=20=20=20(should=20(equal=20= (read=20printed-nums)=20nums))=0A+=20=20=20=20(should=20(equal=20= printed-nums=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= "(-1=20-65=200=201=2031=20128=20159=201114112=204194176=204194303)"))=0A= +=20=20=20=20(should=20(equal=20(read=20printed-nonprints)=20nonprints))=0A= +=20=20=20=20(should=20(equal=20printed-nonprints=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20"(55296=2057343=20778=2065535=208194=20= 8204)"))))=0A=20=0A=20(provide=20'print-tests)=0A=20;;;=20print-tests.el=20= ends=20here=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_9FE844B9-FF7C-49E0-8210-7A8284BAFAD0-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 04 10:38:49 2020 Received: (at 44155) by debbugs.gnu.org; 4 Nov 2020 15:38:49 +0000 Received: from localhost ([127.0.0.1]:50302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaKs5-0003RQ-Ds for submit@debbugs.gnu.org; Wed, 04 Nov 2020 10:38:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaKs3-0003R9-Mp for 44155@debbugs.gnu.org; Wed, 04 Nov 2020 10:38:48 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41575) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaKrx-0002Dv-Oo; Wed, 04 Nov 2020 10:38:41 -0500 Received: from [176.228.60.248] (port=4000 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kaKrx-00043b-3d; Wed, 04 Nov 2020 10:38:41 -0500 Date: Wed, 04 Nov 2020 17:38:35 +0200 Message-Id: <83lffhb090.fsf@gnu.org> From: Eli Zaretskii To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= In-Reply-To: (message from Mattias =?utf-8?Q?Engdeg=C3=A5rd?= on Wed, 4 Nov 2020 12:03:32 +0100) Subject: Re: bug#44155: Print integers as characters References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> <83y2jib5c7.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias EngdegÃ¥rd > Date: Wed, 4 Nov 2020 12:03:32 +0100 > Cc: juri@linkov.net, schwab@suse.de, 44155@debbugs.gnu.org > > 'Printable' was used informally, not in an exact technical meaning. Intuitively, it should be the set of characters that make sense to print using the '?X' syntax. I initially thought that 'graphic' was too technical but it is more precise. 'Independently printable graphic character' is descriptive but a mouthful; perhaps 'independent graphic char' would do? I'm not sure. I think we should use something more familiar, or explain it in more detail. We already mention Unicode properties elsewhere in the manual, so we could define this in those terms, and send the reader there for the details, for example. > For the ?X syntax to make sense, X must be visible; thus controls are out, and so are formatting chars (language tags etc). Spaces should probably have been excluded as well since it's typically not possible to see what kind of space follows the '?' (SPC is explicitly rendered as ?\s). > > Furthermore, X must be independent since it isn't a grapheme cluster but a single code point. Therefore combining chars cannot be included as they would attach to the '?'. > > 'graphicp' cannot be used because it includes combining, enclosing and nonspacing marks (M) and formats (Cf); otherwise it's fine. > > While we could put the exact list of excluded general categories in the documentation, it is not very important because the selection only matters for usability and aesthetics, not (realistically) for code behaviour. > > The attached patch excludes spaces (Zs) and revises the terminology. I'm not going to argue about this aspect, but just FTR: whether to include combining characters is a decision that we make here, it is not a necessity. Because we are perfectly capable of displaying combining characters without risking them to become composed with surrounding characters: we could either precede them with U+25CC DOTTED CIRCLE, or use the technique describe-char-padded-string in descr-text.el uses. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 04 11:46:55 2020 Received: (at 44155) by debbugs.gnu.org; 4 Nov 2020 16:46:55 +0000 Received: from localhost ([127.0.0.1]:50415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaLvy-0007Jc-KA for submit@debbugs.gnu.org; Wed, 04 Nov 2020 11:46:54 -0500 Received: from mail231c50.megamailservers.eu ([91.136.10.241]:40030 helo=mail37c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaLvs-0007JM-MV for 44155@debbugs.gnu.org; Wed, 04 Nov 2020 11:46:52 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604508406; bh=StBpJWr1D1j1MSHuLvcoZEEGId0TOjsOPKJUB1iPW/M=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=eU2wFCMzfMgm+uTbl15FTfyJdzcrMEH+yhyXlomlXJDn2A1oZkqvupa81A76CizSF 4oERF0w8g2/Bo0tZq0hC4e+UI4aLXeJdc9fh2w/+X2aryiusSpAvR5sm7DR3eqMXKc pEbp/Gqak1xBC0K+d+0tNSt49v7t8Wbkk9tHwENg= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail37c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A4GkhKX001718; Wed, 4 Nov 2020 16:46:45 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_F00CDEE6-E171-4989-86D2-33C25E1A02CC" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters Date: Wed, 4 Nov 2020 17:46:42 +0100 In-Reply-To: <83lffhb090.fsf@gnu.org> To: Eli Zaretskii References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> <83y2jib5c7.fsf@gnu.org> <83lffhb090.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F25.5FA2DAF6.0061, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=WZBylHpX c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=Mo0XVvOFbFN8q9cEbkQA:9 a=CjuIK1q_8ugA:10 a=8vRBGogvbazS6joDgeoA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 4 nov. 2020 kl. 16.38 skrev Eli Zaretskii : > I'm not sure. I think we should use something more familiar, or > explain it in more detail. We already mention Unicode properties > elsewhere in the manual, so we could define this in those terms, [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_F00CDEE6-E171-4989-86D2-33C25E1A02CC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 4 nov. 2020 kl. 16.38 skrev Eli Zaretskii : > I'm not sure. I think we should use something more familiar, or > explain it in more detail. We already mention Unicode properties > elsewhere in the manual, so we could define this in those terms, and > send the reader there for the details, for example. Thanks for the review. Please look at the revised patch below with your = requested changes. > I'm not going to argue about this aspect, but just FTR: whether to > include combining characters is a decision that we make here, it is > not a necessity. Because we are perfectly capable of displaying > combining characters without risking them to become composed with > surrounding characters: we could either precede them with U+25CC > DOTTED CIRCLE, or use the technique describe-char-padded-string in > descr-text.el uses. No we cannot, because the output must be valid Lisp. --Apple-Mail=_F00CDEE6-E171-4989-86D2-33C25E1A02CC Content-Disposition: attachment; filename=0001-Reduce-integer-output-format-to-print-integers-as-ch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Reduce-integer-output-format-to-print-integers-as-ch.patch" Content-Transfer-Encoding: quoted-printable =46rom=20aadbdd31b85e8b4459d903ef1bed1fdf8272588f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=202=20Nov=202020=2023:37:16=20+0100=0A= Subject:=20[PATCH]=20Reduce=20integer-output-format=20to=20= print-integers-as-characters=0A=0AThe=20variable=20now=20only=20controls=20= whether=20characters=20are=20printed,=20not=0Athe=20radix.=20=20Control=20= chars=20are=20printed=20in=20human-readable=20syntax=0Aonly=20when=20= special=20escapes=20such=20as=20?\n=20are=20available.=20=20Spaces,=0A= formatting=20and=20combining=20chars=20are=20excluded=20(bug#44155).=0A= Done=20in=20collaboration=20with=20Juri=20Linkov.=0A=0A*=20= src/character.c=20(graphic_base_p):=0A*=20src/print.c=20(named_escape):=20= New=20functions.=0A(print_object):=20Change=20semantics=20as=20described=20= above.=0A(syms_of_print):=20Rename=20integer-output-format.=20=20Update=20= doc=20string.=0A*=20doc/lispref/streams.texi=20(Output=20Variables):=0A*=20= etc/NEWS:=0A*=20test/src/print-tests.el=20= (print-integers-as-characters):=0ARename=20and=20update=20according=20to=20= new=20semantics.=20=20The=20test=20now=20passes.=0A---=0A=20= doc/lispref/streams.texi=20|=2013=20++++----=0A=20etc/NEWS=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=2011=20++++---=0A=20= src/character.c=20=20=20=20=20=20=20=20=20=20|=2021=20+++++++++++++=0A=20= src/character.h=20=20=20=20=20=20=20=20=20=20|=20=201=20+=0A=20= src/print.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2064=20= ++++++++++++++++++++++++++--------------=0A=20test/src/print-tests.el=20=20= |=2039=20+++++++++++++-----------=0A=206=20files=20changed,=2097=20= insertions(+),=2052=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/streams.texi=20b/doc/lispref/streams.texi=0Aindex=20= f171f13779..799d35b070=20100644=0A---=20a/doc/lispref/streams.texi=0A+++=20= b/doc/lispref/streams.texi=0A@@=20-903,10=20+903,11=20@@=20Output=20= Variables=0A=20you=20can=20use,=20see=20the=20variable's=20documentation=20= string.=0A=20@end=20defvar=0A=20=0A-@defvar=20integer-output-format=0A= -This=20variable=20specifies=20how=20to=20print=20integer=20numbers.=20=20= The=20default=20is=0A-@code{nil},=20meaning=20use=20the=20decimal=20= format.=20=20When=20bound=20to=20@code{t},=0A-print=20integers=20as=20= characters=20when=20an=20integer=20represents=20a=20character=0A= -(@pxref{Basic=20Char=20Syntax}).=20=20When=20bound=20to=20the=20number=20= @code{16},=0A-print=20non-negative=20integers=20in=20the=20hexadecimal=20= format.=0A+@defvar=20print-integers-as-characters=0A+When=20this=20= variable=20is=20non-@code{nil},=20integers=20that=20represent=0A= +independent=20graphic=20characters=20or=20control=20characters=20with=20= their=20own=0A+escape=20syntax=20such=20as=20newline=20will=20be=20= printed=20using=20Lisp=20character=0A+syntax=20(@pxref{Basic=20Char=20= Syntax}).=20=20Other=20numbers=20are=20printed=20the=0A+usual=20way.=20=20= For=20example,=20the=20list=20@code{(4=2065=20-1=2010)}=20will=20be=20= printed=0A+as=20@samp{(4=20?A=20-1=20?\n)}.=0A=20@end=20defvar=0Adiff=20= --git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=20d15f3ed1ae..e3ac15f7e3=20= 100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-1697,12=20+1697,6=20= @@=20ledit.el,=20lmenu.el,=20lucid.el=20and=20old-whitespace.el.=0A=20=0C= =0A=20*=20Lisp=20Changes=20in=20Emacs=2028.1=0A=20=0A-**=20New=20= variable=20'integer-output-format'=20determines=20how=20to=20print=20= integer=20values.=0A-When=20this=20variable=20is=20bound=20to=20the=20= value=20't',=20integers=20are=20printed=20by=0A-printing=20functions=20= as=20characters=20when=20an=20integer=20represents=20a=20character.=0A= -When=20bound=20to=20the=20number=2016,=20non-negative=20integers=20are=20= printed=20in=20the=0A-hexadecimal=20format.=0A-=0A=20+++=0A=20**=20= 'define-globalized-minor-mode'=20now=20takes=20a=20':predicate'=20= parameter.=0A=20This=20can=20be=20used=20to=20control=20which=20major=20= modes=20the=20minor=20mode=20should=20be=0A@@=20-1895,6=20+1889,11=20@@=20= file=20can=20affect=20code=20in=20another.=20=20For=20details,=20see=20= the=20manual=20section=0A=20'replace-regexp-in-string',=20'catch',=20= 'throw',=20'error',=20'signal'=0A=20and=20'play-sound-file'.=0A=20=0A= ++++=0A+**=20New=20variable=20'print-integers-as-characters'=20modifies=20= integer=20printing.=0A+When=20this=20variable=20is=20non-nil,=20= character=20syntax=20is=20used=20for=20printing=0A+numbers=20for=20which=20= this=20makes=20sense,=20such=20as=20'?*'=20for=2042.=0A+=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0A= diff=20--git=20a/src/character.c=20b/src/character.c=0Aindex=20= 5860f6a0c8..00b73293a3=20100644=0A---=20a/src/character.c=0A+++=20= b/src/character.c=0A@@=20-982,6=20+982,27=20@@=20printablep=20(int=20c)=0A= =20=09=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20= unassigned=20*/=0A=20}=0A=20=0A+/*=20Return=20true=20if=20C=20is=20= graphic=20character=20that=20can=20be=20printed=20independently.=20=20*/=0A= +bool=0A+graphic_base_p=20(int=20c)=0A+{=0A+=20=20Lisp_Object=20category=20= =3D=20CHAR_TABLE_REF=20(Vunicode_category_table,=20c);=0A+=20=20if=20(!=20= FIXNUMP=20(category))=0A+=20=20=20=20return=20false;=0A+=20=20EMACS_INT=20= gen_cat=20=3D=20XFIXNUM=20(category);=0A+=0A+=20=20return=20(!(gen_cat=20= =3D=3D=20UNICODE_CATEGORY_Mn=20=20=20=20=20=20=20/*=20mark,=20nonspacing=20= */=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Mc=20=20=20=20/*=20mark,=20combining=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Me=20=20= =20=20/*=20mark,=20enclosing=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zs=20=20=20=20/*=20separator,=20= space=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Zl=20=20=20=20/*=20separator,=20line=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zp=20=20= =20=20/*=20separator,=20paragraph=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20= =20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cc=20=20=20=20/*=20other,=20= control=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Cs=20=20=20=20/*=20other,=20surrogate=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cf=20=20= =20=20/*=20other,=20format=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20other,=20= unassigned=20*/=0A+}=0A+=0A=20/*=20Return=20true=20if=20C=20is=20a=20= horizontal=20whitespace=20character,=20as=20defined=0A=20=20=20=20by=20= https://www.unicode.org/reports/tr18/tr18-19.html#blank.=20=20*/=0A=20= bool=0Adiff=20--git=20a/src/character.h=20b/src/character.h=0Aindex=20= af5023f77c..cbf43097ae=20100644=0A---=20a/src/character.h=0A+++=20= b/src/character.h=0A@@=20-583,6=20+583,7=20@@=20char_surrogate_p=20(int=20= c)=0A=20extern=20bool=20graphicp=20(int);=0A=20extern=20bool=20= printablep=20(int);=0A=20extern=20bool=20blankp=20(int);=0A+extern=20= bool=20graphic_base_p=20(int);=0A=20=0A=20/*=20Look=20up=20the=20element=20= in=20char=20table=20OBJ=20at=20index=20CH,=20and=20return=20it=20as=0A=20= =20=20=20an=20integer.=20=20If=20the=20element=20is=20not=20a=20= character,=20return=20CH=20itself.=20=20*/=0Adiff=20--git=20= a/src/print.c=20b/src/print.c=0Aindex=20fa65a3cb26..f2e2dd131d=20100644=0A= ---=20a/src/print.c=0A+++=20b/src/print.c=0A@@=20-1848,6=20+1848,24=20@@=20= print_vectorlike=20(Lisp_Object=20obj,=20Lisp_Object=20printcharfun,=20= bool=20escapeflag,=0A=20=20=20return=20true;=0A=20}=0A=20=0A+static=20= char=0A+named_escape=20(int=20i)=0A+{=0A+=20=20switch=20(i)=0A+=20=20=20=20= {=0A+=20=20=20=20case=20'\b':=20return=20'b';=0A+=20=20=20=20case=20= '\t':=20return=20't';=0A+=20=20=20=20case=20'\n':=20return=20'n';=0A+=20=20= =20=20case=20'\f':=20return=20'f';=0A+=20=20=20=20case=20'\r':=20return=20= 'r';=0A+=20=20=20=20case=20'=20':=20=20return=20's';=0A+=20=20=20=20=20=20= /*=20\a,=20\v,=20\e=20and=20\d=20are=20excluded=20from=20printing=20as=20= escapes=20since=0A+=20=20=20=20=20=20=20=20=20they=20are=20somewhat=20= rare=20as=20characters=20and=20more=20likely=20to=20be=0A+=20=20=20=20=20= =20=20=20=20plain=20integers.=20*/=0A+=20=20=20=20}=0A+=20=20return=200;=0A= +}=0A+=0A=20static=20void=0A=20print_object=20(Lisp_Object=20obj,=20= Lisp_Object=20printcharfun,=20bool=20escapeflag)=0A=20{=0A@@=20-1908,29=20= +1926,30=20@@=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag)=0A=20=20=20=20=20{=0A=20=20=20=20=20= case_Lisp_Int:=0A=20=20=20=20=20=20=20{=0A-=09int=20c;=0A-=09intmax_t=20= i;=0A+=20=20=20=20=20=20=20=20EMACS_INT=20i=20=3D=20XFIXNUM=20(obj);=0A+=20= =20=20=20=20=20=20=20char=20escaped_name;=0A=20=0A-=09if=20(EQ=20= (Vinteger_output_format,=20Qt)=20&&=20CHARACTERP=20(obj)=0A-=09=20=20=20=20= &&=20(c=20=3D=20XFIXNUM=20(obj)))=0A+=09if=20= (print_integers_as_characters=20&&=20i=20>=3D=200=20&&=20i=20<=3D=20= MAX_UNICODE_CHAR=0A+=20=20=20=20=20=20=20=20=20=20=20=20&&=20= ((escaped_name=20=3D=20named_escape=20(i))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20||=20graphic_base_p=20(i)))=0A=20=09=20=20{=0A=20=09= =20=20=20=20printchar=20('?',=20printcharfun);=0A-=09=20=20=20=20if=20= (escapeflag=0A-=09=09&&=20(c=20=3D=3D=20';'=20||=20c=20=3D=3D=20'('=20||=20= c=20=3D=3D=20')'=20||=20c=20=3D=3D=20'{'=20||=20c=20=3D=3D=20'}'=0A-=09=09= =20=20=20=20||=20c=20=3D=3D=20'['=20||=20c=20=3D=3D=20']'=20||=20c=20=3D=3D= =20'\"'=20||=20c=20=3D=3D=20'\''=20||=20c=20=3D=3D=20'\\'))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20if=20(escaped_name)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= printchar=20('\\',=20printcharfun);=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20i=20=3D=20escaped_name;=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20else=20if=20(escapeflag=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20(i=20= =3D=3D=20';'=20||=20i=20=3D=3D=20'\"'=20||=20i=20=3D=3D=20'\''=20||=20i=20= =3D=3D=20'\\'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20||=20i=20=3D=3D=20'('=20||=20i=20=3D=3D=20')'=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20= i=20=3D=3D=20'{'=20||=20i=20=3D=3D=20'}'=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D=20'['=20||=20= i=20=3D=3D=20']'))=0A=20=09=20=20=20=20=20=20printchar=20('\\',=20= printcharfun);=0A-=09=20=20=20=20printchar=20(c,=20printcharfun);=0A-=09=20= =20}=0A-=09else=20if=20(INTEGERP=20(Vinteger_output_format)=0A-=09=09=20= &&=20integer_to_intmax=20(Vinteger_output_format,=20&i)=0A-=09=09=20&&=20= i=20=3D=3D=2016=20&&=20!NILP=20(Fnatnump=20(obj)))=0A-=09=20=20{=0A-=09=20= =20=20=20int=20len=20=3D=20sprintf=20(buf,=20"#x%"pI"x",=20(EMACS_UINT)=20= XFIXNUM=20(obj));=0A-=09=20=20=20=20strout=20(buf,=20len,=20len,=20= printcharfun);=0A+=09=20=20=20=20printchar=20(i,=20printcharfun);=0A=20=09= =20=20}=0A=20=09else=0A=20=09=20=20{=0A-=09=20=20=20=20int=20len=20=3D=20= sprintf=20(buf,=20"%"pI"d",=20XFIXNUM=20(obj));=0A+=09=20=20=20=20int=20= len=20=3D=20sprintf=20(buf,=20"%"pI"d",=20i);=0A=20=09=20=20=20=20strout=20= (buf,=20len,=20len,=20printcharfun);=0A=20=09=20=20}=0A=20=20=20=20=20=20= =20}=0A@@=20-2270,12=20+2289,13=20@@=20syms_of_print=20(void)=0A=20that=20= represents=20the=20number=20without=20losing=20information.=20=20*/);=0A=20= =20=20Vfloat_output_format=20=3D=20Qnil;=0A=20=0A-=20=20DEFVAR_LISP=20= ("integer-output-format",=20Vinteger_output_format,=0A-=09=20=20=20=20=20= =20=20doc:=20/*=20The=20format=20used=20to=20print=20integers.=0A-When=20= t,=20print=20characters=20from=20integers=20that=20represent=20a=20= character.=0A-When=20a=20number=2016,=20print=20non-negative=20integers=20= in=20the=20hexadecimal=20format.=0A-Otherwise,=20by=20default=20print=20= integers=20in=20the=20decimal=20format.=20=20*/);=0A-=20=20= Vinteger_output_format=20=3D=20Qnil;=0A+=20=20DEFVAR_BOOL=20= ("print-integers-as-characters",=20print_integers_as_characters,=0A+=09=20= =20=20=20=20=20=20doc:=20/*=20Non-nil=20means=20integers=20are=20printed=20= using=20characters=20syntax.=0A+Only=20independent=20graphic=20= characters,=20and=20control=20characters=20with=20named=0A+escape=20= sequences=20such=20as=20newline,=20are=20printed=20this=20way.=20=20= Other=0A+integers,=20including=20those=20corresponding=20to=20raw=20= bytes,=20are=20printed=0A+affected.=20=20*/);=0A+=20=20= print_integers_as_characters=20=3D=20Qnil;=0A=20=0A=20=20=20DEFVAR_LISP=20= ("print-length",=20Vprint_length,=0A=20=09=20=20=20=20=20=20=20doc:=20/*=20= Maximum=20length=20of=20list=20to=20print=20before=20abbreviating.=0A= diff=20--git=20a/test/src/print-tests.el=20b/test/src/print-tests.el=0A= index=207b026b6b21..202555adb3=20100644=0A---=20= a/test/src/print-tests.el=0A+++=20b/test/src/print-tests.el=0A@@=20= -383,25=20+383,28=20@@=20print-hash-table-test=0A=20=20=20=20=20=20=20= (let=20((print-length=201))=0A=20=20=20=20=20=20=20=20=20(format=20"%S"=20= h))))))=0A=20=0A-(print-tests--deftest=20print-integer-output-format=20= ()=0A+(print-tests--deftest=20print-integers-as-characters=20()=0A=20=20=20= ;;=20Bug#44155.=0A-=20=20(let=20((integer-output-format=20t)=0A-=20=20=20= =20=20=20=20=20(syms=20(list=20??=20?\;=20?\(=20?\)=20?\{=20?\}=20?\[=20= ?\]=20?\"=20?\'=20?\\=20?=C3=81)))=0A-=20=20=20=20(should=20(equal=20= (read=20(print-tests--prin1-to-string=20syms))=20syms))=0A-=20=20=20=20= (should=20(equal=20(print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=20= #'prin1-char=20syms=20"=20")=20")"))))=0A-=20=20(let=20= ((integer-output-format=20t)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20?\120=204194175=204194176=20(max-char)=20(1+=20= (max-char)))))=0A-=20=20=20=20(should=20(equal=20(read=20= (print-tests--prin1-to-string=20syms))=20syms)))=0A-=20=20(let=20= ((integer-output-format=2016)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20most-positive-fixnum=20(1+=20most-positive-fixnum))))=0A-=20= =20=20=20(should=20(equal=20(read=20(print-tests--prin1-to-string=20= syms))=20syms))=0A-=20=20=20=20(should=20(equal=20= (print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (lambda=20(i)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20(>=3D=20i=200)=20= (<=3D=20i=20most-positive-fixnum))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(format=20"#x%x"=20i)=20(format=20"%d"=20i)))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= syms=20"=20")=20")")))))=0A+=20=20(let*=20((print-integers-as-characters=20= t)=0A+=20=20=20=20=20=20=20=20=20(chars=20'(??=20?\;=20?\(=20?\)=20?\{=20= ?\}=20?\[=20?\]=20?\"=20?\'=20?\\=20?f=20?~=20?=C3=81=2032=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20?\n=20?\r=20?\t=20?\b=20?\f=20= ?\a=20?\v=20?\e=20?\d))=0A+=20=20=20=20=20=20=20=20=20(nums=20'(-1=20-65=20= 0=201=2031=20#x80=20#x9f=20#x110000=20#x3fff80=20#x3fffff))=0A+=20=20=20=20= =20=20=20=20=20(nonprints=20'(#xd800=20#xdfff=20#x030a=20#xffff=20#x2002=20= #x200c))=0A+=20=20=20=20=20=20=20=20=20(printed-chars=20= (print-tests--prin1-to-string=20chars))=0A+=20=20=20=20=20=20=20=20=20= (printed-nums=20(print-tests--prin1-to-string=20nums))=0A+=20=20=20=20=20= =20=20=20=20(printed-nonprints=20(print-tests--prin1-to-string=20= nonprints)))=0A+=20=20=20=20(should=20(equal=20(read=20printed-chars)=20= chars))=0A+=20=20=20=20(should=20(equal=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20printed-chars=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20"(??=20?\\;=20?\\(=20?\\)=20= ?\\{=20?\\}=20?\\[=20?\\]=20?\\\"=20?\\'=20?\\\\"=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"=20?f=20?~=20?=C3=81=20?\\s=20?\\n=20?\\r=20?\\t=20= ?\\b=20?\\f=207=2011=2027=20127)")))=0A+=20=20=20=20(should=20(equal=20= (read=20printed-nums)=20nums))=0A+=20=20=20=20(should=20(equal=20= printed-nums=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= "(-1=20-65=200=201=2031=20128=20159=201114112=204194176=204194303)"))=0A= +=20=20=20=20(should=20(equal=20(read=20printed-nonprints)=20nonprints))=0A= +=20=20=20=20(should=20(equal=20printed-nonprints=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20"(55296=2057343=20778=2065535=208194=20= 8204)"))))=0A=20=0A=20(provide=20'print-tests)=0A=20;;;=20print-tests.el=20= ends=20here=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_F00CDEE6-E171-4989-86D2-33C25E1A02CC-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 04 11:58:10 2020 Received: (at 44155) by debbugs.gnu.org; 4 Nov 2020 16:58:10 +0000 Received: from localhost ([127.0.0.1]:50463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaM6s-0007dh-Jc for submit@debbugs.gnu.org; Wed, 04 Nov 2020 11:58:10 -0500 Received: from mail79c50.megamailservers.eu ([91.136.10.89]:57854 helo=mail70c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaM6p-0007dX-Nj for 44155@debbugs.gnu.org; Wed, 04 Nov 2020 11:58:09 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604509086; bh=VZ4OQBO7/K5EI+3qQWlsQHXM/4l7d8liPmB8JUhM1RA=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=EbR2tCD97P43BPwtV9zqW2tuzfuv+LGOPGfyb7fDDz11qL8XNsOxT3OD6kmSCpO2m z/xMC7gqPoxkMQVMh8ncJwDyLzf03lXUY2jWhsKAy0S/YX7BaVf0NoDZ8DnvyeIbCe gMyiF4VFLiFgRfvRU74fMyQBwVQVebmbArbsfNXg= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A4Gw3uQ030897; Wed, 4 Nov 2020 16:58:04 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_613662AB-95A0-4061-B77C-20AA19A7CF44" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters Date: Wed, 4 Nov 2020 17:58:02 +0100 In-Reply-To: To: Eli Zaretskii References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> <83y2jib5c7.fsf@gnu.org> <83lffhb090.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F21.5FA2DD9E.0009, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=H6ulPNQi c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=2WRZgn4w7lo6qwKW3QUA:9 a=CjuIK1q_8ugA:10 a=8vRBGogvbazS6joDgeoA:9 a=B2y7HmGcmWMA:10 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The last patch was incorrect; here is the right one. Apologies for the confusion. Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155 Cc: 44155@debbugs.gnu.org, schwab@suse.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_613662AB-95A0-4061-B77C-20AA19A7CF44 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii The last patch was incorrect; here is the right one. Apologies for the = confusion. --Apple-Mail=_613662AB-95A0-4061-B77C-20AA19A7CF44 Content-Disposition: attachment; filename=0001-Reduce-integer-output-format-to-print-integers-as-ch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Reduce-integer-output-format-to-print-integers-as-ch.patch" Content-Transfer-Encoding: quoted-printable =46rom=202a7bd3b8393f182e42d77e929d5e02a137c8e89b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=202=20Nov=202020=2023:37:16=20+0100=0A= Subject:=20[PATCH]=20Reduce=20integer-output-format=20to=20= print-integers-as-characters=0A=0AThe=20variable=20now=20only=20controls=20= whether=20characters=20are=20printed,=20not=0Athe=20radix.=20=20Control=20= chars=20are=20printed=20in=20human-readable=20syntax=0Aonly=20when=20= special=20escapes=20such=20as=20?\n=20are=20available.=20=20Spaces,=0A= formatting=20and=20combining=20chars=20are=20excluded=20(bug#44155).=0A= Done=20in=20collaboration=20with=20Juri=20Linkov.=0A=0A*=20= src/character.c=20(graphic_base_p):=0A*=20src/print.c=20(named_escape):=20= New=20functions.=0A(print_object):=20Change=20semantics=20as=20described=20= above.=0A(syms_of_print):=20Rename=20integer-output-format.=20=20Update=20= doc=20string.=0A*=20doc/lispref/streams.texi=20(Output=20Variables):=0A*=20= etc/NEWS:=0A*=20test/src/print-tests.el=20= (print-integers-as-characters):=0ARename=20and=20update=20according=20to=20= new=20semantics.=20=20The=20test=20now=20passes.=0A---=0A=20= doc/lispref/streams.texi=20|=2018=20+++++++----=0A=20etc/NEWS=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20|=2011=20++++---=0A=20= src/character.c=20=20=20=20=20=20=20=20=20=20|=2021=20+++++++++++++=0A=20= src/character.h=20=20=20=20=20=20=20=20=20=20|=20=201=20+=0A=20= src/print.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2064=20= ++++++++++++++++++++++++++--------------=0A=20test/src/print-tests.el=20=20= |=2039=20+++++++++++++-----------=0A=206=20files=20changed,=20102=20= insertions(+),=2052=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/streams.texi=20b/doc/lispref/streams.texi=0Aindex=20= f171f13779..0534afb67f=20100644=0A---=20a/doc/lispref/streams.texi=0A+++=20= b/doc/lispref/streams.texi=0A@@=20-903,10=20+903,16=20@@=20Output=20= Variables=0A=20you=20can=20use,=20see=20the=20variable's=20documentation=20= string.=0A=20@end=20defvar=0A=20=0A-@defvar=20integer-output-format=0A= -This=20variable=20specifies=20how=20to=20print=20integer=20numbers.=20=20= The=20default=20is=0A-@code{nil},=20meaning=20use=20the=20decimal=20= format.=20=20When=20bound=20to=20@code{t},=0A-print=20integers=20as=20= characters=20when=20an=20integer=20represents=20a=20character=0A= -(@pxref{Basic=20Char=20Syntax}).=20=20When=20bound=20to=20the=20number=20= @code{16},=0A-print=20non-negative=20integers=20in=20the=20hexadecimal=20= format.=0A+@defvar=20print-integers-as-characters=0A+When=20this=20= variable=20is=20non-@code{nil},=20integers=20that=20represent=0A+graphic=20= base=20characters=20will=20be=20printed=20using=20Lisp=20character=20= syntax=0A+(@pxref{Basic=20Char=20Syntax}).=20Other=20numbers=20are=20= printed=20the=20usual=20way.=0A+For=20example,=20the=20list=20@code{(4=20= 65=20-1=2010)}=20would=20be=20printed=20as=0A+@samp{(4=20?A=20-1=20= ?\n)}.=0A+=0A+More=20precisely,=20values=20printed=20in=20character=20= syntax=20are=20those=0A+representing=20characters=20belonging=20to=20the=20= Unicode=20general=20categories=0A+Letter,=20Number,=20Punctuation,=20= Symbol=20and=20Private-use=0A+(@pxref{Character=20Properties}),=20as=20= well=20as=20the=20control=20characters=0A+having=20their=20own=20escape=20= syntax=20such=20as=20newline.=0A=20@end=20defvar=0Adiff=20--git=20= a/etc/NEWS=20b/etc/NEWS=0Aindex=20d15f3ed1ae..9dcdcc3079=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-1697,12=20+1697,6=20@@=20ledit.el,=20= lmenu.el,=20lucid.el=20and=20old-whitespace.el.=0A=20=0C=0A=20*=20Lisp=20= Changes=20in=20Emacs=2028.1=0A=20=0A-**=20New=20variable=20= 'integer-output-format'=20determines=20how=20to=20print=20integer=20= values.=0A-When=20this=20variable=20is=20bound=20to=20the=20value=20't',=20= integers=20are=20printed=20by=0A-printing=20functions=20as=20characters=20= when=20an=20integer=20represents=20a=20character.=0A-When=20bound=20to=20= the=20number=2016,=20non-negative=20integers=20are=20printed=20in=20the=0A= -hexadecimal=20format.=0A-=0A=20+++=0A=20**=20= 'define-globalized-minor-mode'=20now=20takes=20a=20':predicate'=20= parameter.=0A=20This=20can=20be=20used=20to=20control=20which=20major=20= modes=20the=20minor=20mode=20should=20be=0A@@=20-1895,6=20+1889,11=20@@=20= file=20can=20affect=20code=20in=20another.=20=20For=20details,=20see=20= the=20manual=20section=0A=20'replace-regexp-in-string',=20'catch',=20= 'throw',=20'error',=20'signal'=0A=20and=20'play-sound-file'.=0A=20=0A= ++++=0A+**=20New=20variable=20'print-integers-as-characters'=20modifies=20= integer=20printing.=0A+If=20this=20variable=20is=20non-nil,=20character=20= syntax=20is=20used=20for=20printing=0A+numbers=20when=20this=20makes=20= sense,=20such=20as=20'?A'=20for=2065.=0A+=0A=20=0C=0A=20*=20Changes=20in=20= Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0Adiff=20--git=20= a/src/character.c=20b/src/character.c=0Aindex=205860f6a0c8..00b73293a3=20= 100644=0A---=20a/src/character.c=0A+++=20b/src/character.c=0A@@=20-982,6=20= +982,27=20@@=20printablep=20(int=20c)=0A=20=09=20=20=20=20||=20gen_cat=20= =3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20unassigned=20*/=0A=20}=0A=20=0A= +/*=20Return=20true=20if=20C=20is=20graphic=20character=20that=20can=20= be=20printed=20independently.=20=20*/=0A+bool=0A+graphic_base_p=20(int=20= c)=0A+{=0A+=20=20Lisp_Object=20category=20=3D=20CHAR_TABLE_REF=20= (Vunicode_category_table,=20c);=0A+=20=20if=20(!=20FIXNUMP=20(category))=0A= +=20=20=20=20return=20false;=0A+=20=20EMACS_INT=20gen_cat=20=3D=20= XFIXNUM=20(category);=0A+=0A+=20=20return=20(!(gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Mn=20=20=20=20=20=20=20/*=20mark,=20nonspacing=20*/=0A+=20= =20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Mc=20=20=20=20/*=20mark,=20combining=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Me=20=20= =20=20/*=20mark,=20enclosing=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zs=20=20=20=20/*=20separator,=20= space=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Zl=20=20=20=20/*=20separator,=20line=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Zp=20=20= =20=20/*=20separator,=20paragraph=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20= =20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cc=20=20=20=20/*=20other,=20= control=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20= UNICODE_CATEGORY_Cs=20=20=20=20/*=20other,=20surrogate=20*/=0A+=20=20=20=20= =20=20=20=20=20=20=20=20||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cf=20=20= =20=20/*=20other,=20format=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ||=20gen_cat=20=3D=3D=20UNICODE_CATEGORY_Cn));=20/*=20other,=20= unassigned=20*/=0A+}=0A+=0A=20/*=20Return=20true=20if=20C=20is=20a=20= horizontal=20whitespace=20character,=20as=20defined=0A=20=20=20=20by=20= https://www.unicode.org/reports/tr18/tr18-19.html#blank.=20=20*/=0A=20= bool=0Adiff=20--git=20a/src/character.h=20b/src/character.h=0Aindex=20= af5023f77c..cbf43097ae=20100644=0A---=20a/src/character.h=0A+++=20= b/src/character.h=0A@@=20-583,6=20+583,7=20@@=20char_surrogate_p=20(int=20= c)=0A=20extern=20bool=20graphicp=20(int);=0A=20extern=20bool=20= printablep=20(int);=0A=20extern=20bool=20blankp=20(int);=0A+extern=20= bool=20graphic_base_p=20(int);=0A=20=0A=20/*=20Look=20up=20the=20element=20= in=20char=20table=20OBJ=20at=20index=20CH,=20and=20return=20it=20as=0A=20= =20=20=20an=20integer.=20=20If=20the=20element=20is=20not=20a=20= character,=20return=20CH=20itself.=20=20*/=0Adiff=20--git=20= a/src/print.c=20b/src/print.c=0Aindex=20fa65a3cb26..f2e2dd131d=20100644=0A= ---=20a/src/print.c=0A+++=20b/src/print.c=0A@@=20-1848,6=20+1848,24=20@@=20= print_vectorlike=20(Lisp_Object=20obj,=20Lisp_Object=20printcharfun,=20= bool=20escapeflag,=0A=20=20=20return=20true;=0A=20}=0A=20=0A+static=20= char=0A+named_escape=20(int=20i)=0A+{=0A+=20=20switch=20(i)=0A+=20=20=20=20= {=0A+=20=20=20=20case=20'\b':=20return=20'b';=0A+=20=20=20=20case=20= '\t':=20return=20't';=0A+=20=20=20=20case=20'\n':=20return=20'n';=0A+=20=20= =20=20case=20'\f':=20return=20'f';=0A+=20=20=20=20case=20'\r':=20return=20= 'r';=0A+=20=20=20=20case=20'=20':=20=20return=20's';=0A+=20=20=20=20=20=20= /*=20\a,=20\v,=20\e=20and=20\d=20are=20excluded=20from=20printing=20as=20= escapes=20since=0A+=20=20=20=20=20=20=20=20=20they=20are=20somewhat=20= rare=20as=20characters=20and=20more=20likely=20to=20be=0A+=20=20=20=20=20= =20=20=20=20plain=20integers.=20*/=0A+=20=20=20=20}=0A+=20=20return=200;=0A= +}=0A+=0A=20static=20void=0A=20print_object=20(Lisp_Object=20obj,=20= Lisp_Object=20printcharfun,=20bool=20escapeflag)=0A=20{=0A@@=20-1908,29=20= +1926,30=20@@=20print_object=20(Lisp_Object=20obj,=20Lisp_Object=20= printcharfun,=20bool=20escapeflag)=0A=20=20=20=20=20{=0A=20=20=20=20=20= case_Lisp_Int:=0A=20=20=20=20=20=20=20{=0A-=09int=20c;=0A-=09intmax_t=20= i;=0A+=20=20=20=20=20=20=20=20EMACS_INT=20i=20=3D=20XFIXNUM=20(obj);=0A+=20= =20=20=20=20=20=20=20char=20escaped_name;=0A=20=0A-=09if=20(EQ=20= (Vinteger_output_format,=20Qt)=20&&=20CHARACTERP=20(obj)=0A-=09=20=20=20=20= &&=20(c=20=3D=20XFIXNUM=20(obj)))=0A+=09if=20= (print_integers_as_characters=20&&=20i=20>=3D=200=20&&=20i=20<=3D=20= MAX_UNICODE_CHAR=0A+=20=20=20=20=20=20=20=20=20=20=20=20&&=20= ((escaped_name=20=3D=20named_escape=20(i))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20||=20graphic_base_p=20(i)))=0A=20=09=20=20{=0A=20=09= =20=20=20=20printchar=20('?',=20printcharfun);=0A-=09=20=20=20=20if=20= (escapeflag=0A-=09=09&&=20(c=20=3D=3D=20';'=20||=20c=20=3D=3D=20'('=20||=20= c=20=3D=3D=20')'=20||=20c=20=3D=3D=20'{'=20||=20c=20=3D=3D=20'}'=0A-=09=09= =20=20=20=20||=20c=20=3D=3D=20'['=20||=20c=20=3D=3D=20']'=20||=20c=20=3D=3D= =20'\"'=20||=20c=20=3D=3D=20'\''=20||=20c=20=3D=3D=20'\\'))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20if=20(escaped_name)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= printchar=20('\\',=20printcharfun);=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20i=20=3D=20escaped_name;=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20}=0A+=20=20=20=20=20=20=20=20=20=20=20=20else=20if=20(escapeflag=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20(i=20= =3D=3D=20';'=20||=20i=20=3D=3D=20'\"'=20||=20i=20=3D=3D=20'\''=20||=20i=20= =3D=3D=20'\\'=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20||=20i=20=3D=3D=20'('=20||=20i=20=3D=3D=20')'=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20= i=20=3D=3D=20'{'=20||=20i=20=3D=3D=20'}'=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20i=20=3D=3D=20'['=20||=20= i=20=3D=3D=20']'))=0A=20=09=20=20=20=20=20=20printchar=20('\\',=20= printcharfun);=0A-=09=20=20=20=20printchar=20(c,=20printcharfun);=0A-=09=20= =20}=0A-=09else=20if=20(INTEGERP=20(Vinteger_output_format)=0A-=09=09=20= &&=20integer_to_intmax=20(Vinteger_output_format,=20&i)=0A-=09=09=20&&=20= i=20=3D=3D=2016=20&&=20!NILP=20(Fnatnump=20(obj)))=0A-=09=20=20{=0A-=09=20= =20=20=20int=20len=20=3D=20sprintf=20(buf,=20"#x%"pI"x",=20(EMACS_UINT)=20= XFIXNUM=20(obj));=0A-=09=20=20=20=20strout=20(buf,=20len,=20len,=20= printcharfun);=0A+=09=20=20=20=20printchar=20(i,=20printcharfun);=0A=20=09= =20=20}=0A=20=09else=0A=20=09=20=20{=0A-=09=20=20=20=20int=20len=20=3D=20= sprintf=20(buf,=20"%"pI"d",=20XFIXNUM=20(obj));=0A+=09=20=20=20=20int=20= len=20=3D=20sprintf=20(buf,=20"%"pI"d",=20i);=0A=20=09=20=20=20=20strout=20= (buf,=20len,=20len,=20printcharfun);=0A=20=09=20=20}=0A=20=20=20=20=20=20= =20}=0A@@=20-2270,12=20+2289,13=20@@=20syms_of_print=20(void)=0A=20that=20= represents=20the=20number=20without=20losing=20information.=20=20*/);=0A=20= =20=20Vfloat_output_format=20=3D=20Qnil;=0A=20=0A-=20=20DEFVAR_LISP=20= ("integer-output-format",=20Vinteger_output_format,=0A-=09=20=20=20=20=20= =20=20doc:=20/*=20The=20format=20used=20to=20print=20integers.=0A-When=20= t,=20print=20characters=20from=20integers=20that=20represent=20a=20= character.=0A-When=20a=20number=2016,=20print=20non-negative=20integers=20= in=20the=20hexadecimal=20format.=0A-Otherwise,=20by=20default=20print=20= integers=20in=20the=20decimal=20format.=20=20*/);=0A-=20=20= Vinteger_output_format=20=3D=20Qnil;=0A+=20=20DEFVAR_BOOL=20= ("print-integers-as-characters",=20print_integers_as_characters,=0A+=09=20= =20=20=20=20=20=20doc:=20/*=20Non-nil=20means=20integers=20are=20printed=20= using=20characters=20syntax.=0A+Only=20independent=20graphic=20= characters,=20and=20control=20characters=20with=20named=0A+escape=20= sequences=20such=20as=20newline,=20are=20printed=20this=20way.=20=20= Other=0A+integers,=20including=20those=20corresponding=20to=20raw=20= bytes,=20are=20printed=0A+affected.=20=20*/);=0A+=20=20= print_integers_as_characters=20=3D=20Qnil;=0A=20=0A=20=20=20DEFVAR_LISP=20= ("print-length",=20Vprint_length,=0A=20=09=20=20=20=20=20=20=20doc:=20/*=20= Maximum=20length=20of=20list=20to=20print=20before=20abbreviating.=0A= diff=20--git=20a/test/src/print-tests.el=20b/test/src/print-tests.el=0A= index=207b026b6b21..202555adb3=20100644=0A---=20= a/test/src/print-tests.el=0A+++=20b/test/src/print-tests.el=0A@@=20= -383,25=20+383,28=20@@=20print-hash-table-test=0A=20=20=20=20=20=20=20= (let=20((print-length=201))=0A=20=20=20=20=20=20=20=20=20(format=20"%S"=20= h))))))=0A=20=0A-(print-tests--deftest=20print-integer-output-format=20= ()=0A+(print-tests--deftest=20print-integers-as-characters=20()=0A=20=20=20= ;;=20Bug#44155.=0A-=20=20(let=20((integer-output-format=20t)=0A-=20=20=20= =20=20=20=20=20(syms=20(list=20??=20?\;=20?\(=20?\)=20?\{=20?\}=20?\[=20= ?\]=20?\"=20?\'=20?\\=20?=C3=81)))=0A-=20=20=20=20(should=20(equal=20= (read=20(print-tests--prin1-to-string=20syms))=20syms))=0A-=20=20=20=20= (should=20(equal=20(print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=20= #'prin1-char=20syms=20"=20")=20")"))))=0A-=20=20(let=20= ((integer-output-format=20t)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20?\120=204194175=204194176=20(max-char)=20(1+=20= (max-char)))))=0A-=20=20=20=20(should=20(equal=20(read=20= (print-tests--prin1-to-string=20syms))=20syms)))=0A-=20=20(let=20= ((integer-output-format=2016)=0A-=20=20=20=20=20=20=20=20(syms=20(list=20= -1=200=201=20most-positive-fixnum=20(1+=20most-positive-fixnum))))=0A-=20= =20=20=20(should=20(equal=20(read=20(print-tests--prin1-to-string=20= syms))=20syms))=0A-=20=20=20=20(should=20(equal=20= (print-tests--prin1-to-string=20syms)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(concat=20"("=20(mapconcat=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (lambda=20(i)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20(>=3D=20i=200)=20= (<=3D=20i=20most-positive-fixnum))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(format=20"#x%x"=20i)=20(format=20"%d"=20i)))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= syms=20"=20")=20")")))))=0A+=20=20(let*=20((print-integers-as-characters=20= t)=0A+=20=20=20=20=20=20=20=20=20(chars=20'(??=20?\;=20?\(=20?\)=20?\{=20= ?\}=20?\[=20?\]=20?\"=20?\'=20?\\=20?f=20?~=20?=C3=81=2032=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20?\n=20?\r=20?\t=20?\b=20?\f=20= ?\a=20?\v=20?\e=20?\d))=0A+=20=20=20=20=20=20=20=20=20(nums=20'(-1=20-65=20= 0=201=2031=20#x80=20#x9f=20#x110000=20#x3fff80=20#x3fffff))=0A+=20=20=20=20= =20=20=20=20=20(nonprints=20'(#xd800=20#xdfff=20#x030a=20#xffff=20#x2002=20= #x200c))=0A+=20=20=20=20=20=20=20=20=20(printed-chars=20= (print-tests--prin1-to-string=20chars))=0A+=20=20=20=20=20=20=20=20=20= (printed-nums=20(print-tests--prin1-to-string=20nums))=0A+=20=20=20=20=20= =20=20=20=20(printed-nonprints=20(print-tests--prin1-to-string=20= nonprints)))=0A+=20=20=20=20(should=20(equal=20(read=20printed-chars)=20= chars))=0A+=20=20=20=20(should=20(equal=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20printed-chars=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20"(??=20?\\;=20?\\(=20?\\)=20= ?\\{=20?\\}=20?\\[=20?\\]=20?\\\"=20?\\'=20?\\\\"=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"=20?f=20?~=20?=C3=81=20?\\s=20?\\n=20?\\r=20?\\t=20= ?\\b=20?\\f=207=2011=2027=20127)")))=0A+=20=20=20=20(should=20(equal=20= (read=20printed-nums)=20nums))=0A+=20=20=20=20(should=20(equal=20= printed-nums=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= "(-1=20-65=200=201=2031=20128=20159=201114112=204194176=204194303)"))=0A= +=20=20=20=20(should=20(equal=20(read=20printed-nonprints)=20nonprints))=0A= +=20=20=20=20(should=20(equal=20printed-nonprints=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20"(55296=2057343=20778=2065535=208194=20= 8204)"))))=0A=20=0A=20(provide=20'print-tests)=0A=20;;;=20print-tests.el=20= ends=20here=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_613662AB-95A0-4061-B77C-20AA19A7CF44-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 06 08:03:12 2020 Received: (at 44155-done) by debbugs.gnu.org; 6 Nov 2020 13:03:12 +0000 Received: from localhost ([127.0.0.1]:55356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kb1Oa-0005AY-5X for submit@debbugs.gnu.org; Fri, 06 Nov 2020 08:03:12 -0500 Received: from mail1479c50.megamailservers.eu ([91.136.14.79]:33388 helo=mail118c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kb1OX-0005AD-6U for 44155-done@debbugs.gnu.org; Fri, 06 Nov 2020 08:03:10 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1604667782; bh=eat6f6MP7B3lOWBCOCWOS91ysNJo89/k6O40syHWh5o=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=jIgrSJUCK9S/ce+jsKPqu1OiZ8jWmWDawExNecrYwu3zf6zKLH6/HUFn3t3SDlgIS fKuUd8HwORZvLO7lofj5Pv5q7chc8ruIk4emCg7tqXU7KXJGXiwGJRDCVvieTdu8WM M/OJ2cDHT8SISSJGsUWNzCVm5TogDvbdiXRXR3ls= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0A6D2xDq004776; Fri, 6 Nov 2020 13:03:01 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#44155: Print integers as characters From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Fri, 6 Nov 2020 14:02:59 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <871rhd3peq.fsf@mail.linkov.net> <608FF40B-D8F6-471E-8036-4779D892E987@acm.org> <87imanigpd.fsf@mail.linkov.net> <83ft5qcvl6.fsf@gnu.org> <650DFF04-509F-4B8C-9C53-F38DC10B9F97@acm.org> <83y2jib5c7.fsf@gnu.org> <83lffhb090.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F23.5FA54986.0060, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=U/Ps8tju c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=N54-gffFAAAA:8 a=OD75-2WVDQnUKIgJoWUA:9 a=QEXdDO2ut3YA:10 a=v7zKWsmy5NQA:10 a=Qzt0FRFQUfIA:10 a=6l0D2HzqY3Epnrm8mE3f:22 X-Origin-Country: SE X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 4 nov. 2020 kl. 17.58 skrev Mattias EngdegÃ¥rd : > The last patch was incorrect; here is the right one. Apologies for the confusion. Pushed to master, since there wasn't much left to discuss. As usual, it can be modified or reverted as needed. Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.3 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 44155-done Cc: 44155-done@debbugs.gnu.org, Andreas Schwab , Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 4 nov. 2020 kl. 17.58 skrev Mattias Engdeg=C3=A5rd : > The last patch was incorrect; here is the right one. Apologies for the = confusion. Pushed to master, since there wasn't much left to discuss. As usual, it = can be modified or reverted as needed. From unknown Tue Aug 19 10:01:23 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 05 Dec 2020 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator