From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: larsi@gnus.org, bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Apr 2025 21:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 77656@debbugs.gnu.org Cc: Lars Ingebrigtsen X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Lars Ingebrigtsen Received: via spool by submit@debbugs.gnu.org id=B.17441485331055 (code B ref -1); Tue, 08 Apr 2025 21:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Apr 2025 21:42:13 +0000 Received: from localhost ([127.0.0.1]:35849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2Ghw-0000Gw-BN for submit@debbugs.gnu.org; Tue, 08 Apr 2025 17:42:12 -0400 Received: from lists.gnu.org ([2001:470:142::17]:34412) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2Ght-0000GZ-JP for submit@debbugs.gnu.org; Tue, 08 Apr 2025 17:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2Ghl-0002ra-SV for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 17:42:02 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2Ghi-0006P2-O6 for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 17:42:01 -0400 From: Spencer Baugh Date: Tue, 08 Apr 2025 17:41:56 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744148516; bh=g8aTYjVJATjloZ8ggGujheXuzta0+MPiRhAA6PGrLPI=; h=From:To:Subject:Date; b=en1sCCTQ2lPu2yqS+kglnomTAqBbhfszFXePY/SSaQtipUrA6MkS8/RJuHMawCx4J xBnd80rgVGwY6bcf5a9+MGVap2EpHKWmJfZuZSaEtAcEPiY+yT4PWZ5o0h3a4o4HTn TGxy+990kujQpPippvjYmJWK9mHvgBf8MCy/4Wq0uqigMgoct1tBzqXwki9ZCb8Dc5 DXSWbwcUhZDqwmn1i+qqy21+7CQh3RGi9s2vKtdIC4QJx+SnAm9bzVcwD9bz/V+QVM 1b+nud1Q/YFegdA7VRhqFwLqrW6QqJaWeacMTCyW8HduSa35e2dlGqBkBC2NCgjQQ0 djpmoh9VwOGmQ== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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.1 (/) --=-=-= Content-Type: text/plain Tags: patch This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which removed some unnecessary escaping of "." and "?" when printing symbols in prin1. This change removes more unnecessary escaping of "."; "." only needs to be escaped when it's the entire symbol or if it's followed by a "?". (Actually, if we always escaped "?" (which was the case before 637dde4aba92) then "." only ever needs to be escaped when string_to_number returns non-nil. So 637dde4aba92 could have just dropped the escaping of "." with no other changes, if it didn't also remove escaping of "?") In GNU Emacs 30.1.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-04-08 built on igm-qws-u22796a Repository revision: 66de38ffb76fbd3ecb1cea52e655189b1b173fa1 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-tree-sitter --with-native-compilation=aot' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Don-t-escape-.-in-prin1-unless-followed-by-or-nothin.patch >From debb205a42505eac022c51886732304d026db8a8 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 4 Jun 2024 10:35:10 -0400 Subject: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which removed some unnecessary escaping of "." and "?" when printing symbols in prin1. This change removes more unnecessary escaping of "."; "." only needs to be escaped when it's the entire symbol or if it's followed by a "?". (Actually, if we always escaped "?" (which was the case before 637dde4aba92) then "." only ever needs to be escaped when string_to_number returns non-nil. So 637dde4aba92 could have just dropped the escaping of "." with no other changes, if it didn't also remove escaping of "?") * src/print.c (print_object): Only escape "." as the first character in a symbol if followed by "?" or nothing. * test/src/print-tests.el (test-dots): Update for new behavior. --- src/print.c | 8 +++++--- test/src/print-tests.el | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/print.c b/src/print.c index c7cba5bface..c8ab73f6275 100644 --- a/src/print.c +++ b/src/print.c @@ -2442,10 +2442,12 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) ((c_isdigit (p[signedp]) || p[signedp] == '.') && !NILP (string_to_number (p, 10, &len)) && len == size_byte) - /* We don't escape "." or "?" (unless they're the first - character in the symbol name). */ + /* We don't escape "?" unless it's the first character in the + symbol name. */ || *p == '?' - || *p == '.'; + /* We don't escape "." unless it's the entire symbol name, or + followed by a "?". */ + || (*p == '.' && (size_byte == 1 || *(p+1) == '?')) ; if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj)) diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 1a04cf73f30..34254963e6d 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -415,8 +415,8 @@ test-unreadable (ert-deftest test-dots () (should (equal (prin1-to-string 'foo.bar) "foo.bar")) - (should (equal (prin1-to-string '.foo) "\\.foo")) - (should (equal (prin1-to-string '.foo.) "\\.foo.")) + (should (equal (prin1-to-string '.foo) ".foo")) + (should (equal (prin1-to-string '.foo.) ".foo.")) (should (equal (prin1-to-string 'bar?bar) "bar?bar")) (should (equal (prin1-to-string '\?bar) "\\?bar")) (should (equal (prin1-to-string '\?bar?) "\\?bar?"))) -- 2.39.3 --=-=-=-- From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Apr 2025 11:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh , Stefan Monnier , Stefan Kangas , Andrea Corallo Cc: larsi@gnus.org, 77656@debbugs.gnu.org Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.174445646513487 (code B ref 77656); Sat, 12 Apr 2025 11:15:02 +0000 Received: (at 77656) by debbugs.gnu.org; 12 Apr 2025 11:14:25 +0000 Received: from localhost ([127.0.0.1]:54233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u3Yoa-0003VT-P6 for submit@debbugs.gnu.org; Sat, 12 Apr 2025 07:14:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u3YoX-0003VF-JS for 77656@debbugs.gnu.org; Sat, 12 Apr 2025 07:14:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3YoR-0003Gv-Qa; Sat, 12 Apr 2025 07:14:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1fcJ+KquM0HU98U8WFZP+zuEfMWbG2eBpHhGfb9BveM=; b=CpWhNcTXwN77 gHLSPnzgG4IfJaAZK12loxnGxHUooA+VIz/s4XokVMm1hkHFxsX0pkDJSPgeJDrHiM0VMit2gtwpa tVifJtxWuK8cwQPhC0XC6kJv1GDLHuMCx4kT0HVA8KpgKd/To2aNLWEuqpOj2JehjobhhZ0CojJPQ mijnRm1p+eQdRUDa+6Fj2YkIx35DCTr/CT8WCjti9MXxQF/4Bqe+9cxyvQOCYrq0BSFk/d4PFtOWK Ueo8+OA2DwO1KHTVJVEfWvsO0fL3c91MI3TGw01TwogxBCGe8XjScyTdzbIqxyUw1TCenUkjnk54i /hT8FnYTqoi6G9tSSchEEw==; Date: Sat, 12 Apr 2025 14:14:12 +0300 Message-Id: <86ikn9my2j.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: X-Spam-Score: -2.3 (--) 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 (---) > Cc: Lars Ingebrigtsen > Date: Tue, 08 Apr 2025 17:41:56 -0400 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which > removed some unnecessary escaping of "." and "?" when printing symbols > in prin1. > > This change removes more unnecessary escaping of "."; "." only > needs to be escaped when it's the entire symbol or if it's > followed by a "?". > > (Actually, if we always escaped "?" (which was the case before > 637dde4aba92) then "." only ever needs to be escaped when > string_to_number returns non-nil. So 637dde4aba92 could have > just dropped the escaping of "." with no other changes, if it > didn't also remove escaping of "?") Any objections or comments, anyone? From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Apr 2025 13:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii , Spencer Baugh , Stefan Monnier , Andrea Corallo Cc: larsi@gnus.org, 77656@debbugs.gnu.org Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.174446484825210 (code B ref 77656); Sat, 12 Apr 2025 13:35:02 +0000 Received: (at 77656) by debbugs.gnu.org; 12 Apr 2025 13:34:08 +0000 Received: from localhost ([127.0.0.1]:54604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u3azo-0006YX-1Y for submit@debbugs.gnu.org; Sat, 12 Apr 2025 09:34:08 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:49399) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u3azl-0006XW-Jw for 77656@debbugs.gnu.org; Sat, 12 Apr 2025 09:34:06 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5e5cd420781so5701054a12.2 for <77656@debbugs.gnu.org>; Sat, 12 Apr 2025 06:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744464839; x=1745069639; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=JdD6euRbaW10heZ6tVM0jpzNvT1Qn68H1WUwYB11SP8=; b=JwyC5yJTyKvbvLr3KvuWvpptKhMs7JRW16lfGrV/7CrJCVLC65qIFubJ5Z1LiIhtYT mDTPeoMkB70a+txWVOa92clUaxv8XoWW5FA059k4xcwtgX7jbo+WsjrWz7uwdt9ZMuSK 9qQLZF1bfyU6CwUy9Mhl0yTpRYcXOEjRg8jrGiW8CB0r2ePFy0X2iSLckE/5ISzgzoSh G1IA55ui8mFzavT67gBCiu9oL3cJU4P2HGewzCBxnfK23Ack7gvkLVDmt3ZtppBVy/i5 WnoVZiUop+Je7s9faz2yor+RAwee9s3+VII4T3Uq5UJVpFwmcLADG2YaEXYzPATnT3gS IYuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744464839; x=1745069639; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JdD6euRbaW10heZ6tVM0jpzNvT1Qn68H1WUwYB11SP8=; b=mLPXtzwRoRFOKKjuX2cBkuGgb6/GX0nA1HzamyFkxxO35ASG6e5ABKkZAEHgv2/hFD 0yDLxwiXSkz8Jg12IywuF6ZkXMnEp96xrEPNy2BFynKEtCAxKP13AvO8iZaFWhhuGrrx FPGWMUrFVs16ilQ1ZuP8qo4t/FAaYBJXosW+sfoupXHfbwqfX8iaEhXfc4BGR9y7o0eU IVCeoqmIe7y1amUUVPoKRgJnPpznCaUgQiS9CiXb1Gall+y26S2mE1iNA3AU4IduIFoL JOMDhsJtsr0Ny+cdbqsgZgYZ1P/aZx8z3KFagGtwN3GRWNZWVZSLmNPAj39EpHK5Qf0c nCEA== X-Gm-Message-State: AOJu0YxbByPutB7VkByQp/VnyP/AuqDcn+RhpBfOCjEbd/Z2IF+IdCcB UMHEfORt2C8nTZ8naM3vecILfYcTA4StkOctUqA6k9CKtdvQ51jsWWrTpgAbw1PMJN2dwKDQAin 3tTuA/v0jMgjeXfcgGKCeE9Oq6GU= X-Gm-Gg: ASbGncvl8MYSP80z/giZXrzgqkkYH0b6Tspl9zGO6KUI0+xxvEMu1okVOOkQuWcQELN zJaMcPIkcHjCD4d0+Mj/U3sWnllVX+OsRl/qq9QQ34jS6+25Nl9sk9pG57VlX8irCi0WakUwLdr RQyrriLbxO9JGpdQp7swcRFaKw X-Google-Smtp-Source: AGHT+IHsc1Vc1XV0gX75Ne97jpqX44hqQwyT0zNBmp8yv2/su2ga8DNe/y3tqU9NDt10VI40+uwdTstEU4+3S1dS3mQ= X-Received: by 2002:a05:6402:1e90:b0:5e4:c119:7ff8 with SMTP id 4fb4d7f45d1cf-5f36f52ba73mr4335088a12.4.1744464839133; Sat, 12 Apr 2025 06:33:59 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 12 Apr 2025 08:33:58 -0500 Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 12 Apr 2025 08:33:58 -0500 From: Stefan Kangas In-Reply-To: <86ikn9my2j.fsf@gnu.org> References: <86ikn9my2j.fsf@gnu.org> MIME-Version: 1.0 Date: Sat, 12 Apr 2025 08:33:58 -0500 X-Gm-Features: ATxdqUGRk8J0zma7e3uKrzKPKZfhjCVDTrDyCuM5MMFjIDLLS2nGsx7E3S-AwlM Message-ID: Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) 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 (-) Eli Zaretskii writes: >> Cc: Lars Ingebrigtsen >> Date: Tue, 08 Apr 2025 17:41:56 -0400 >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which >> removed some unnecessary escaping of "." and "?" when printing symbols >> in prin1. >> >> This change removes more unnecessary escaping of "."; "." only >> needs to be escaped when it's the entire symbol or if it's >> followed by a "?". >> >> (Actually, if we always escaped "?" (which was the case before >> 637dde4aba92) then "." only ever needs to be escaped when >> string_to_number returns non-nil. So 637dde4aba92 could have >> just dropped the escaping of "." with no other changes, if it >> didn't also remove escaping of "?") > > Any objections or comments, anyone? I guess the difference is this chunk: - (should (equal (prin1-to-string '.foo) "\\.foo")) - (should (equal (prin1-to-string '.foo.) "\\.foo.")) + (should (equal (prin1-to-string '.foo) ".foo")) + (should (equal (prin1-to-string '.foo.) ".foo.")) No objections from me. From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Apr 2025 15:35:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Kangas Cc: Spencer Baugh , Eli Zaretskii , Andrea Corallo , larsi@gnus.org, 77656@debbugs.gnu.org Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.174447206422339 (code B ref 77656); Sat, 12 Apr 2025 15:35:05 +0000 Received: (at 77656) by debbugs.gnu.org; 12 Apr 2025 15:34:24 +0000 Received: from localhost ([127.0.0.1]:57885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u3cs9-0005ny-2k for submit@debbugs.gnu.org; Sat, 12 Apr 2025 11:34:23 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11395) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u3crr-0005kd-LA for 77656@debbugs.gnu.org; Sat, 12 Apr 2025 11:34:06 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4339B440DBC; Sat, 12 Apr 2025 11:33:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1744472036; bh=/9tqleedSse2/Oht3jzV/h6qv3DKpwKDOXy1Cyji3OE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZzFBEIKl3Y3FHOvu7Tc/Z5pXCid0rrmCZHXkDjzHIvmAotPT+WMaFxa2HsI7z6yis nIqYqiBYGxnOCPjB+gw2xsBqiZUuDQ2C4zez4whahuIGZQsVtwbut35FLCEI3+EWo3 kaBsKTEBKVK+F+px0VLQKeEJyYVOSila3RbloLDMTlLDw3oJl/FF5wOswOsx5dsyFD xJsEuQURzT94xmY8tIPhVCotF2vhBJdkXHHbF+9bp4la4kpnTPjzHdQSc37C3eUsex UxzzDioHsUcOHYVovyXQEh9w+07yWK67sHels1vKAkBNIxkdSghHYQ4m0wQnnPnq9u goczT4j6Qzl+A== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3FA324408F5; Sat, 12 Apr 2025 11:33:56 -0400 (EDT) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F009A1204BC; Sat, 12 Apr 2025 11:33:55 -0400 (EDT) From: Stefan Monnier In-Reply-To: Message-ID: References: <86ikn9my2j.fsf@gnu.org> Date: Sat, 12 Apr 2025 11:33:54 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.348 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) 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 (---) >>> This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which >>> removed some unnecessary escaping of "." and "?" when printing symbols >>> in prin1. >>> >>> This change removes more unnecessary escaping of "."; "." only >>> needs to be escaped when it's the entire symbol or if it's >>> followed by a "?". >>> >>> (Actually, if we always escaped "?" (which was the case before >>> 637dde4aba92) then "." only ever needs to be escaped when >>> string_to_number returns non-nil. So 637dde4aba92 could have >>> just dropped the escaping of "." with no other changes, if it >>> didn't also remove escaping of "?") >> >> Any objections or comments, anyone? No real objection, but I'm a bit worried that it seems this is designed based on the idea that `prin1` should be `read`able by the same Emacs that printed it, whereas I think it should aim to generate output that's `read`able also by past and future Emacsen and that it shouldn't unduly restrict future changes to our lexical rules. I *think* the proposed change is OK in this respect, but at the same time I wonder if the gain is really worth the risk. Stefan From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Apr 2025 15:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: larsi@gnus.org, Eli Zaretskii , Andrea Corallo , Stefan Kangas , 77656@debbugs.gnu.org Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.174473209029223 (code B ref 77656); Tue, 15 Apr 2025 15:49:02 +0000 Received: (at 77656) by debbugs.gnu.org; 15 Apr 2025 15:48:10 +0000 Received: from localhost ([127.0.0.1]:53909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4iW9-0007b9-Lf for submit@debbugs.gnu.org; Tue, 15 Apr 2025 11:48:10 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:45919) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4iW6-0007ZZ-6q for 77656@debbugs.gnu.org; Tue, 15 Apr 2025 11:48:07 -0400 From: Spencer Baugh In-Reply-To: (Stefan Monnier's message of "Sat, 12 Apr 2025 11:33:54 -0400") References: <86ikn9my2j.fsf@gnu.org> Date: Tue, 15 Apr 2025 11:48:00 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744732080; bh=P6CMUK9B3PQOkqqsdNmAcVI+qNY1dL65Q1PTiX+L7rA=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=zS2NUzi3dV9jmNMhqiQCzEMgPBH61ES/DNmudzFilmm2aRjCPF9ztHrb5UYGoSs+8 5IlaOmZAM6iTuiNhxnYoXy9WMx6Y8DLxU9LoguAAACjDdAGxCm3LBwMXBhRYcRsM1c tpF1N3Xf8VBOMPL8oy8mp+y4kiE9Cy+fv4s8gjbDYNwQWYP1HoX2RHGu4HQ5wsL+pT WZxcjtqYfgd2snMwZo5TKb/65giiK1dmWb5dPzFEarvLyBLQ9n692Xs16h4AuqmpJr Uxqz+0HUxjOUjHHqN/1WvnwWDjGAvuSonBwnlnrGQFu2x5LOHb54hAIcsqMQoddaU+ zctW46kMW01Og== X-Spam-Score: -2.3 (--) 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 (---) Stefan Monnier writes: >>>> This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which >>>> removed some unnecessary escaping of "." and "?" when printing symbols >>>> in prin1. >>>> >>>> This change removes more unnecessary escaping of "."; "." only >>>> needs to be escaped when it's the entire symbol or if it's >>>> followed by a "?". >>>> >>>> (Actually, if we always escaped "?" (which was the case before >>>> 637dde4aba92) then "." only ever needs to be escaped when >>>> string_to_number returns non-nil. So 637dde4aba92 could have >>>> just dropped the escaping of "." with no other changes, if it >>>> didn't also remove escaping of "?") >>> >>> Any objections or comments, anyone? > > No real objection, but I'm a bit worried that it seems this is designed > based on the idea that `prin1` should be `read`able by the same Emacs > that printed it, whereas I think it should aim to generate output > that's `read`able also by past and future Emacsen and that it shouldn't > unduly restrict future changes to our lexical rules. > > I *think* the proposed change is OK in this respect, but at the same > time I wonder if the gain is really worth the risk. Yes, to be clear I think (though I haven't tested on truly ancient Emacsen) that this is readable by all past versions of Emacs so it's good in that department. As for future Emacsen, I contend that we won't want to change how this lexes in the future - it would break let-alist, for one thing. Incidentally, making it easier to work with let-alist was one of my main motivations for this change, since it ubiquitously uses symbols which start with ".". From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Apr 2025 16:24:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh Cc: larsi@gnus.org, Eli Zaretskii , Andrea Corallo , Stefan Kangas , 77656@debbugs.gnu.org Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.174473419115244 (code B ref 77656); Tue, 15 Apr 2025 16:24:03 +0000 Received: (at 77656) by debbugs.gnu.org; 15 Apr 2025 16:23:11 +0000 Received: from localhost ([127.0.0.1]:54319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4j43-0003xn-FG for submit@debbugs.gnu.org; Tue, 15 Apr 2025 12:23:11 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19198) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4j41-0003xW-NG for 77656@debbugs.gnu.org; Tue, 15 Apr 2025 12:23:10 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6A04780860; Tue, 15 Apr 2025 12:23:03 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1744734182; bh=rLbTg2ysAh3E641uYIiZbwUNIoSOjn4s2CKNrQc7Iz0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jE8rIsoWJZufUS9M96NrE9qKHkzH+zJL2Y+a1+YSeu3l2ec0iXBhv5M7xjLD7jS9Y cnF6LOHX91tH/2FooquNDaWT5mw2UNkgV2gTvwdjhKRl6VfI5si2etelJBeMcFfHW8 aND/obXTIshnxzDlS90uRl+vcUvcbcIXzE+onUYp9ohbG23fu+LYiFi59pHG1mySWD tgjNyfSgbEfOw7NrvNmRjKc84rMY44YhDH1sLhVExCh/B6qdytJuUqIA42AmgxlAif +BIgg0+E84LJ/iFcXmuKeQRVpvkceGMxfNelmKqLM+ZZZBeV0rrHuQHyDmVDLqsSdb ENqOKZLxJstwA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A7ECA80030; Tue, 15 Apr 2025 12:23:02 -0400 (EDT) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6EE7E120637; Tue, 15 Apr 2025 12:23:02 -0400 (EDT) From: Stefan Monnier In-Reply-To: Message-ID: References: <86ikn9my2j.fsf@gnu.org> Date: Tue, 15 Apr 2025 12:23:01 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.375 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) 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 (---) > As for future Emacsen, I contend that we won't want to change how this > lexes in the future - it would break let-alist, for one thing. > > Incidentally, making it easier to work with let-alist was one of my main > motivations for this change, since it ubiquitously uses symbols which > start with ".". Thanks, it's good to have a clear use-case. You might want to mention it in the commit message (tho at least now it's in the associated bug thread). How often/much do we care about the printed form of `let-alist` expressions? Maybe limiting the effect to ". at the beginning of symbol doesn't need to be a escaped if the second char is a letter" would be good enough? Stefan From unknown Wed Jun 18 00:25:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Apr 2025 19:53:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: larsi@gnus.org, Andrea Corallo , Eli Zaretskii , 77656@debbugs.gnu.org, Stefan Kangas Received: via spool by 77656-submit@debbugs.gnu.org id=B77656.17447467814025 (code B ref 77656); Tue, 15 Apr 2025 19:53:03 +0000 Received: (at 77656) by debbugs.gnu.org; 15 Apr 2025 19:53:01 +0000 Received: from localhost ([127.0.0.1]:55965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4mL6-00012q-R8 for submit@debbugs.gnu.org; Tue, 15 Apr 2025 15:53:01 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:49005) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4mL3-00012Z-Uw for 77656@debbugs.gnu.org; Tue, 15 Apr 2025 15:52:58 -0400 From: Spencer Baugh In-Reply-To: (Stefan Monnier's message of "Tue, 15 Apr 2025 12:23:01 -0400") References: <86ikn9my2j.fsf@gnu.org> Date: Tue, 15 Apr 2025 15:52:52 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744746772; bh=5sB5Z91fa9fi3YiaCXIPQ8n1wFcFZiGfF05E0UOVb2g=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=TEgbacrrr9Zbk+oGW6L1tOkXNAwpyFqSulyF/fnoN/sUe/SefPFtRTJ2wiGGi6cNy 9LK/krtNS5kYBRo9WuPyALfLD2tikxWa0qiEeda1cCPQyqk6dNyjJtn0ifuNorWBvV Bn82rr43OB2DvGX6NMDXQthtzvSTb0dsuLMfDuE8pTd+/xIJZVGap4aptW0LT/mig3 5CAwwOkvmWoWrwUdFYVtVp8P1UVd73WDFsRHOlSxmRKNGXquleClatC+B+C6dI26yE Q5ryuoulb5sow+1/cFk9xHbwLo78FXdUgp7ZmBW6ELj8tO81lKMZdUrclIUvz9h42r 1JGmzhs8k8RCQ== X-Spam-Score: -2.3 (--) 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 (---) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> As for future Emacsen, I contend that we won't want to change how this >> lexes in the future - it would break let-alist, for one thing. >> >> Incidentally, making it easier to work with let-alist was one of my main >> motivations for this change, since it ubiquitously uses symbols which >> start with ".". > > Thanks, it's good to have a clear use-case. You might want to mention > it in the commit message (tho at least now it's in the associated bug thread). Sure, done in the attached revised patch. > How often/much do we care about the printed form of `let-alist` expressions? Not often, it's mostly just that it's more convenient when hacking on it (as I was a while back to add numeric indexing), and I figured it was a harmless change. > Maybe limiting the effect to ". at the beginning of symbol doesn't need > to be a escaped if the second char is a letter" would be good enough? That sounds reasonable to me, done in the attached patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-escape-.-in-prin1-when-followed-by-a-letter.patch >From 6db264d4f8ab2a6f520591958263bf61e92f10cc Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 4 Jun 2024 10:35:10 -0400 Subject: [PATCH] Don't escape "." in `prin1' when followed by a letter Among other users, let-alist widely uses symbols which start with a ".". Make those symbols print more nicely by tweaking the escaping rules in print_object to not escape a leading "." followed by a letter. This is a conservative change to avoid constraining future lexer changes. This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which removed some unnecessary escaping of "." and "?" when printing symbols in prin1. (Actually, if we always escaped "?" (which was the case before 637dde4aba92) then "." only ever needs to be escaped when string_to_number returns non-nil. So 637dde4aba92 could have just dropped the escaping of "." with no other changes, if it didn't also remove escaping of "?") * src/print.c (print_object): Don't escape "." as the first character in a symbol if followed by a letter. (bug#77656). * test/src/print-tests.el (test-dots): Update for new behavior. --- src/print.c | 9 ++++++--- test/src/print-tests.el | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/print.c b/src/print.c index c7cba5bface..b17ec337f70 100644 --- a/src/print.c +++ b/src/print.c @@ -2442,10 +2442,13 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) ((c_isdigit (p[signedp]) || p[signedp] == '.') && !NILP (string_to_number (p, 10, &len)) && len == size_byte) - /* We don't escape "." or "?" (unless they're the first - character in the symbol name). */ + /* We don't escape "?" unless it's the first character in the + symbol name. */ || *p == '?' - || *p == '.'; + /* We don't escape "." unless it's the first character in the + symbol name; even then, we don't escape it if it's followed + by [a-zA-Z]. */ + || (*p == '.' && !(size_byte > 1 && c_isalpha (*(p+1)))); if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj)) diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 1a04cf73f30..af57311135b 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -415,8 +415,10 @@ test-unreadable (ert-deftest test-dots () (should (equal (prin1-to-string 'foo.bar) "foo.bar")) - (should (equal (prin1-to-string '.foo) "\\.foo")) - (should (equal (prin1-to-string '.foo.) "\\.foo.")) + (should (equal (prin1-to-string '.foo) ".foo")) + (should (equal (prin1-to-string '.foo.) ".foo.")) + (should (equal (prin1-to-string '.$) "\\.$")) + (should (equal (prin1-to-string '\.) "\\.")) (should (equal (prin1-to-string 'bar?bar) "bar?bar")) (should (equal (prin1-to-string '\?bar) "\\?bar")) (should (equal (prin1-to-string '\?bar?) "\\?bar?"))) -- 2.39.3 --=-=-=-- From unknown Wed Jun 18 00:25:26 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Spencer Baugh Subject: bug#77656: closed (Re: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing) Message-ID: References: X-Gnu-PR-Message: they-closed 77656 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 77656@debbugs.gnu.org Date: Mon, 28 Apr 2025 17:48:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1745862482-16221-1" This is a multi-part message in MIME format... ------------=_1745862482-16221-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothi= ng which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 77656@debbugs.gnu.org. --=20 77656: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D77656 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1745862482-16221-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 77656-done) by debbugs.gnu.org; 28 Apr 2025 17:47:44 +0000 Received: from localhost ([127.0.0.1]:34292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u9SZz-0004Bb-St for submit@debbugs.gnu.org; Mon, 28 Apr 2025 13:47:44 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:61505) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u9SZw-0004AS-80 for 77656-done@debbugs.gnu.org; Mon, 28 Apr 2025 13:47:41 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A94C54425C9; Mon, 28 Apr 2025 13:47:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1745862453; bh=bsKcMMhcOLOpOqf4PZELcekeFKijcxhWXJ+fx3N1rMY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eWWufqQmwXIBUUuM2o25aLdLuSR6GJmgnkFWx3PUOsBx8Dralafunq3iEcdF20qyp mgAUedlNZJhWhC4kkfKAg2HjqnkVHHuO88P7GR7VC9LqhI5ZwkV3c3F2Ghycf5DEhM 9h+8oMgwa1swAQ3BGGpKEL12d+v7tIm5PxriYcJqMABgFWOu6Igt/1ki9cYJe+RTrY fGR4FNE1avgO+jFNvwQxHv4uvw9uoTyFDo/Z/59oLhxowARQT6MdEO0mM6x53q/fI7 JftiDJqd2F7Vzf8Uf3whr4fugx6aAmezf9SJtrpmBfzLszJfjW3lwMShgJmWjwf2aI iDzguDMabUc7w== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AF36144113C; Mon, 28 Apr 2025 13:47:33 -0400 (EDT) Received: from pastel (104-195-232-56.cpe.teksavvy.com [104.195.232.56]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6B7291203DB; Mon, 28 Apr 2025 13:47:33 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing In-Reply-To: Message-ID: References: <86ikn9my2j.fsf@gnu.org> Date: Mon, 28 Apr 2025 13:47:32 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.019 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77656-done Cc: larsi@gnus.org, Andrea Corallo , Eli Zaretskii , 77656-done@debbugs.gnu.org, Stefan Kangas 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 (---) > That sounds reasonable to me, done in the attached patch. Thanks, pushed to `master`, closing, Stefan ------------=_1745862482-16221-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Apr 2025 21:42:13 +0000 Received: from localhost ([127.0.0.1]:35849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2Ghw-0000Gw-BN for submit@debbugs.gnu.org; Tue, 08 Apr 2025 17:42:12 -0400 Received: from lists.gnu.org ([2001:470:142::17]:34412) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2Ght-0000GZ-JP for submit@debbugs.gnu.org; Tue, 08 Apr 2025 17:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2Ghl-0002ra-SV for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 17:42:02 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2Ghi-0006P2-O6 for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 17:42:01 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing X-Debbugs-Cc: Lars Ingebrigtsen Date: Tue, 08 Apr 2025 17:41:56 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744148516; bh=g8aTYjVJATjloZ8ggGujheXuzta0+MPiRhAA6PGrLPI=; h=From:To:Subject:Date; b=en1sCCTQ2lPu2yqS+kglnomTAqBbhfszFXePY/SSaQtipUrA6MkS8/RJuHMawCx4J xBnd80rgVGwY6bcf5a9+MGVap2EpHKWmJfZuZSaEtAcEPiY+yT4PWZ5o0h3a4o4HTn TGxy+990kujQpPippvjYmJWK9mHvgBf8MCy/4Wq0uqigMgoct1tBzqXwki9ZCb8Dc5 DXSWbwcUhZDqwmn1i+qqy21+7CQh3RGi9s2vKtdIC4QJx+SnAm9bzVcwD9bz/V+QVM 1b+nud1Q/YFegdA7VRhqFwLqrW6QqJaWeacMTCyW8HduSa35e2dlGqBkBC2NCgjQQ0 djpmoh9VwOGmQ== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which removed some unnecessary escaping of "." and "?" when printing symbols in prin1. This change removes more unnecessary escaping of "."; "." only needs to be escaped when it's the entire symbol or if it's followed by a "?". (Actually, if we always escaped "?" (which was the case before 637dde4aba92) then "." only ever needs to be escaped when string_to_number returns non-nil. So 637dde4aba92 could have just dropped the escaping of "." with no other changes, if it didn't also remove escaping of "?") In GNU Emacs 30.1.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-04-08 built on igm-qws-u22796a Repository revision: 66de38ffb76fbd3ecb1cea52e655189b1b173fa1 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-tree-sitter --with-native-compilation=aot' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Don-t-escape-.-in-prin1-unless-followed-by-or-nothin.patch >From debb205a42505eac022c51886732304d026db8a8 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 4 Jun 2024 10:35:10 -0400 Subject: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which removed some unnecessary escaping of "." and "?" when printing symbols in prin1. This change removes more unnecessary escaping of "."; "." only needs to be escaped when it's the entire symbol or if it's followed by a "?". (Actually, if we always escaped "?" (which was the case before 637dde4aba92) then "." only ever needs to be escaped when string_to_number returns non-nil. So 637dde4aba92 could have just dropped the escaping of "." with no other changes, if it didn't also remove escaping of "?") * src/print.c (print_object): Only escape "." as the first character in a symbol if followed by "?" or nothing. * test/src/print-tests.el (test-dots): Update for new behavior. --- src/print.c | 8 +++++--- test/src/print-tests.el | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/print.c b/src/print.c index c7cba5bface..c8ab73f6275 100644 --- a/src/print.c +++ b/src/print.c @@ -2442,10 +2442,12 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) ((c_isdigit (p[signedp]) || p[signedp] == '.') && !NILP (string_to_number (p, 10, &len)) && len == size_byte) - /* We don't escape "." or "?" (unless they're the first - character in the symbol name). */ + /* We don't escape "?" unless it's the first character in the + symbol name. */ || *p == '?' - || *p == '.'; + /* We don't escape "." unless it's the entire symbol name, or + followed by a "?". */ + || (*p == '.' && (size_byte == 1 || *(p+1) == '?')) ; if (! NILP (Vprint_gensym) && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj)) diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 1a04cf73f30..34254963e6d 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -415,8 +415,8 @@ test-unreadable (ert-deftest test-dots () (should (equal (prin1-to-string 'foo.bar) "foo.bar")) - (should (equal (prin1-to-string '.foo) "\\.foo")) - (should (equal (prin1-to-string '.foo.) "\\.foo.")) + (should (equal (prin1-to-string '.foo) ".foo")) + (should (equal (prin1-to-string '.foo.) ".foo.")) (should (equal (prin1-to-string 'bar?bar) "bar?bar")) (should (equal (prin1-to-string '\?bar) "\\?bar")) (should (equal (prin1-to-string '\?bar?) "\\?bar?"))) -- 2.39.3 --=-=-=-- ------------=_1745862482-16221-1--