From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Jens Schmidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Aug 2023 13:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 65536@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169296943412969 (code B ref -1); Fri, 25 Aug 2023 13:18:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Aug 2023 13:17:14 +0000 Received: from localhost ([127.0.0.1]:39650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZWgb-0003N6-Ja for submit@debbugs.gnu.org; Fri, 25 Aug 2023 09:17:13 -0400 Received: from lists.gnu.org ([2001:470:142::17]:45700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZWgX-0003Mn-Es for submit@debbugs.gnu.org; Fri, 25 Aug 2023 09:17:12 -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 1qZWgM-0000IV-Gp for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 09:16:58 -0400 Received: from mr4.vodafonemail.de ([145.253.228.164]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZWgI-0000R7-Tu for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 09:16:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-21dec; t=1692969405; bh=weLvxfuz+rzKRBw+Fh7A3dI8IZNt/8cWHlUyk2x0FHw=; h=Message-ID:Date:User-Agent:Content-Language:From:Subject:To: Content-Type:From; b=XCUTQuEKW0nFw4WguJ+AHZHxwXPvhQsFqVC/Un2A0ItSFvGF2aPIJuXIkt7tguyIG wzhjHWTbP1neI6bz8rj1sxGIxN8eST8bECTpHKQFKsEcihbMZTsw9q8PDctPREatjI mfpb+cgss4/MgHsbZjTkFr+FzoDcwEHuE2MbWYt4= Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr4.vodafonemail.de (Postfix) with ESMTPS id 4RXL7x5Ykhz1xxq for ; Fri, 25 Aug 2023 13:16:45 +0000 (UTC) Received: from [192.168.0.138] (unknown [86.33.87.7]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4RXL7s1tnszHnfp for ; Fri, 25 Aug 2023 13:16:38 +0000 (UTC) Message-ID: Date: Fri, 25 Aug 2023 15:16:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: de-DE-frami, en-US From: Jens Schmidt Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-type: clean X-purgate: clean X-purgate-size: 567 X-purgate-ID: 155817::1692969401-9DFFE94E-EE681136/0/0 Received-SPF: pass client-ip=145.253.228.164; envelope-from=jschmidt4gnu@vodafonemail.de; helo=mr4.vodafonemail.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 (-) Not sure about this one, maybe I have overlooked something ... The Emacs Lisp manual says: Notice that all functions are allowed to overwrite the match data unless they’re explicitly documented not to do so. And in particular function `replace-regexp-in-string' could be assumed to modify the match data, but it uses an explicit call to `save-match-data' to not do so. Maybe this should be explicitly documented in its doc string and/or the Emacs Lisp manual ((elisp) Search and Replace) so that users of the function can rely on that fact? From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Aug 2023 14:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jens Schmidt Cc: 65536@debbugs.gnu.org Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.169297310120266 (code B ref 65536); Fri, 25 Aug 2023 14:19:01 +0000 Received: (at 65536) by debbugs.gnu.org; 25 Aug 2023 14:18:21 +0000 Received: from localhost ([127.0.0.1]:41024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZXdl-0005Gn-6G for submit@debbugs.gnu.org; Fri, 25 Aug 2023 10:18:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZXdk-0005GZ-8X for 65536@debbugs.gnu.org; Fri, 25 Aug 2023 10:18:20 -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 1qZXdZ-00042M-UZ; Fri, 25 Aug 2023 10:18:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=XUhP6lDGZ5MW1SfuNKjPfT6arivDN9xpcJ39I85bTVc=; b=IurAAsc7Z33dF6qIQ5ue netxALu3IZ1lXZ1zsjr4CWMdQsuaR2E0DOw6JjeAXsA4Iq4+lb/jHXNZcj/Hy5EwCtxZGteoFxCOc PEYALqY3YO+2WtX6A92kxXzNGGE3YxBn+7MS8xWegUSWbvZ/IzN6QR9uWYz/gZo8UoDD4a8WDDzRi yFP2yM3vmycD3+QpIQmAVGjxGk8lkr06T+fqpzDGMv56/thLyuwSgbYTPziZuw5wy56jMpmFxnOVc 4YHudTCGpJG9cYpAEr5PCi6L28TlnTY5OZo+JmkAMeDDZtGEkDsEtHh9jIzCUMz8o7BKhf3/xHOo7 s0gyu2ycI/qnBw==; Date: Fri, 25 Aug 2023 17:18:36 +0300 Message-Id: <837cpjnr2b.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 (---) > Date: Fri, 25 Aug 2023 15:16:29 +0200 > From: Jens Schmidt via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Not sure about this one, maybe I have overlooked something ... > > The Emacs Lisp manual says: > > Notice that all functions are allowed to overwrite the match data > unless they’re explicitly documented not to do so. > > And in particular function `replace-regexp-in-string' could be > assumed to modify the match data, but it uses an explicit call to > `save-match-data' to not do so. > > Maybe this should be explicitly documented in its doc string and/or > the Emacs Lisp manual ((elisp) Search and Replace) so that users of > the function can rely on that fact? Is it important to promise never to clobber match-data in this function? From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Jens Schmidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Aug 2023 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 65536@debbugs.gnu.org Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.169297719527228 (code B ref 65536); Fri, 25 Aug 2023 15:27:02 +0000 Received: (at 65536) by debbugs.gnu.org; 25 Aug 2023 15:26:35 +0000 Received: from localhost ([127.0.0.1]:41088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZYhn-000756-9D for submit@debbugs.gnu.org; Fri, 25 Aug 2023 11:26:35 -0400 Received: from mr3.vodafonemail.de ([145.253.228.163]:59756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZYhj-00074q-Kz for 65536@debbugs.gnu.org; Fri, 25 Aug 2023 11:26:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-21dec; t=1692977180; bh=YGNgwlDhackqlzG450iBsRRE4XwvJj0a/nAvwr7lQf8=; h=Message-ID:Date:User-Agent:Subject:Content-Language:To:References: From:In-Reply-To:Content-Type:From; b=JulirduykOuFd/EA3LNbdzu/6up8xKfUQe1eFyK0ZMegBup5b5+WydXnia+yPMcC9 jT6KDu1m3VeoToPrilMY0KWjdSwJTzsgpvZcN+vKjmaCgTXKh/VkMwyzL84l98CHin scZt5YOfBlMyPC2TVlYj99yqcbkLYKY1KYTj6INI= Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr3.vodafonemail.de (Postfix) with ESMTPS id 4RXP1S6FkGz1yrt; Fri, 25 Aug 2023 15:26:20 +0000 (UTC) Received: from [192.168.0.138] (unknown [86.33.87.7]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4RXP1J5BmxzMm7F; Fri, 25 Aug 2023 15:26:09 +0000 (UTC) Message-ID: <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> Date: Fri, 25 Aug 2023 17:26:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: de-DE-frami, en-US References: <837cpjnr2b.fsf@gnu.org> From: Jens Schmidt In-Reply-To: <837cpjnr2b.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-purgate-type: clean X-purgate: clean X-purgate-size: 1348 X-purgate-ID: 155817::1692977176-B0FF5228-40E042B3/0/0 X-Spam-Score: -1.7 (-) 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.7 (--) On 2023-08-25 16:18, Eli Zaretskii wrote: >> Date: Fri, 25 Aug 2023 15:16:29 +0200 >> From: Jens Schmidt via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> Maybe this should be explicitly documented in its doc string and/or >> the Emacs Lisp manual ((elisp) Search and Replace) so that users of >> the function can rely on that fact? > > Is it important to promise never to clobber match-data in this > function? Not sure whether the following is convincing enough ... - I came across this question in the following scenario: (match-fat-regexp with a lot of subres, one of which matches quoted chars: "\\(?5:\\(?:[[:alnum:]_]+\\|\\\\.\\)+\\)") (let ((a (match-string 1 input)) ;; unquote quoted chars (b (replace-regexp-in-string "\\\\\\(.\\)" "\\1" (match-string 5 input) t nil)) (c (match-string 7 input))) ...) So for that and similar scenarios it would be helpful. - And since `replace-regexp-in-string' contains that `save-match-data' for a long time already (at least since Emacs 23) I guess that a lot of authors have been relying on that fact, either consciously, after having peeked into the function, or unconsciously. - If it helps, I could provide a patch ... From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Jens Schmidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Aug 2023 16:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 65536@debbugs.gnu.org Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.16929826044911 (code B ref 65536); Fri, 25 Aug 2023 16:57:02 +0000 Received: (at 65536) by debbugs.gnu.org; 25 Aug 2023 16:56:44 +0000 Received: from localhost ([127.0.0.1]:41168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZa72-0001H8-1N for submit@debbugs.gnu.org; Fri, 25 Aug 2023 12:56:44 -0400 Received: from mr4.vodafonemail.de ([145.253.228.164]:38308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZa6v-0001Gp-QH for 65536@debbugs.gnu.org; Fri, 25 Aug 2023 12:56:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-21dec; t=1692982587; bh=kuSYbfu7D1hRlipBGfzVf9NBuWOgnpFHS8H3R6fzC8w=; h=Message-ID:Date:User-Agent:Subject:Content-Language:From:To: References:In-Reply-To:Content-Type:From; b=q2gdzJEztSo3js7hysG+VfxjMgH4f3pUJwo6Kmdr1L3sfda6oNySLdqEGBrWP6EwH 5s2StBPY4Shd+SvqrRCYUh92TF9wx8E5hPac8i3h+PIzqsw9LWgwSf+RKcXEqmzBx2 l9GBK1sZdCYXXjOXxhy/suTWt2h94lB7O1g9nzw8= Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr4.vodafonemail.de (Postfix) with ESMTPS id 4RXR1R4hqmz1y14; Fri, 25 Aug 2023 16:56:27 +0000 (UTC) Received: from [192.168.0.138] (unknown [86.33.87.7]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4RXR1J0DtCz9s4p; Fri, 25 Aug 2023 16:56:16 +0000 (UTC) Message-ID: Date: Fri, 25 Aug 2023 18:56:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: de-DE-frami, en-US From: Jens Schmidt References: <837cpjnr2b.fsf@gnu.org> <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> In-Reply-To: <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-type: clean X-purgate: clean X-purgate-size: 1061 X-purgate-ID: 155817::1692982583-7B7FFE22-8FE41E1A/0/0 X-Spam-Score: -1.7 (-) 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.7 (--) On 2023-08-25 17:26, Jens Schmidt wrote: > On 2023-08-25 16:18, Eli Zaretskii wrote: >>> Date: Fri, 25 Aug 2023 15:16:29 +0200 >>> From: Jens Schmidt via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" > >>> Maybe this should be explicitly documented in its doc string and/or >>> the Emacs Lisp manual ((elisp) Search and Replace) so that users of >>> the function can rely on that fact? >> >> Is it important to promise never to clobber match-data in this >> function? > > Not sure whether the following is convincing enough ... OTOH, I just found the following in the doc string of `save-match-data', which means that `replace-regexp-in-string' is actually not "convention-conforming": NOTE: The convention in Elisp is that any function, except for a few exceptions like car/assoc/+/goto-char, can clobber the match data, so ‘save-match-data’ should normally be used to save *your* match data rather than your caller’s match data. The final decision is yours ... From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 06:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jens Schmidt , Stefan Kangas Cc: 65536@debbugs.gnu.org Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.16930301363987 (code B ref 65536); Sat, 26 Aug 2023 06:09:01 +0000 Received: (at 65536) by debbugs.gnu.org; 26 Aug 2023 06:08:56 +0000 Received: from localhost ([127.0.0.1]:41534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZmTg-00012F-An for submit@debbugs.gnu.org; Sat, 26 Aug 2023 02:08:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37370) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZmTd-00011z-Rb for 65536@debbugs.gnu.org; Sat, 26 Aug 2023 02:08:54 -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 1qZmTS-0001x5-PG; Sat, 26 Aug 2023 02:08:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=pzvEoXRH5v3zaCH2e6JfOgaUqrkOZcDFwFv4Aub8YEU=; b=kIdIHc+lnMHQxtdJOpw7 MAhpPxncPitPH7ikmysemlpS1JObWtIiCWbUKo2ROpEd5w1sHt6s3fN7TOsXPX3DYR/B3Yz9oo53c 1+xNkXYChvWJMnTQR9Wn+qhBcb70cUUDAbrC9BD93DR33loqZHFnuZ8o6joERz+XbFmReXncnTfcj +HWcTzRCaBdwIljoBgLBmqTjDggWMLHM/84jjXp21TVtoaRy+EV3hkJ5WT/xp1PWjejFQItxYRZag romYE89sC2rHFQoy0Yw/XFDA1hahGZpBRtrca7Kfnva35eRbWrzFzNsqU3al2dBpzX9L/UP1DkaYC QEvPfQ3Yjw/fIQ==; Date: Sat, 26 Aug 2023 09:09:11 +0300 Message-Id: <83il92mj20.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Jens Schmidt on Fri, 25 Aug 2023 18:56:15 +0200) References: <837cpjnr2b.fsf@gnu.org> <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 (---) > Date: Fri, 25 Aug 2023 18:56:15 +0200 > From: Jens Schmidt > Cc: 65536@debbugs.gnu.org > > On 2023-08-25 17:26, Jens Schmidt wrote: > > On 2023-08-25 16:18, Eli Zaretskii wrote: > >>> Date: Fri, 25 Aug 2023 15:16:29 +0200 > >>> From: Jens Schmidt via "Bug reports for GNU Emacs, > >>> the Swiss army knife of text editors" > > > >>> Maybe this should be explicitly documented in its doc string and/or > >>> the Emacs Lisp manual ((elisp) Search and Replace) so that users of > >>> the function can rely on that fact? > >> > >> Is it important to promise never to clobber match-data in this > >> function? > > > > Not sure whether the following is convincing enough ... > > OTOH, I just found the following in the doc string of > `save-match-data', which means that `replace-regexp-in-string' > is actually not "convention-conforming": > > NOTE: The convention in Elisp is that any function, except for a few > exceptions like car/assoc/+/goto-char, can clobber the match data, > so ‘save-match-data’ should normally be used to save *your* match data > rather than your caller’s match data. > > The final decision is yours ... I think it's okay to leave things as they are. Stefan, WDYT? From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 06:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 65536@debbugs.gnu.org, Jens Schmidt , Stefan Kangas Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.16930310875423 (code B ref 65536); Sat, 26 Aug 2023 06:25:01 +0000 Received: (at 65536) by debbugs.gnu.org; 26 Aug 2023 06:24:47 +0000 Received: from localhost ([127.0.0.1]:41539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZmj1-0001PP-0X for submit@debbugs.gnu.org; Sat, 26 Aug 2023 02:24:47 -0400 Received: from mout01.posteo.de ([185.67.36.65]:58647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZmiy-0001P9-4x for 65536@debbugs.gnu.org; Sat, 26 Aug 2023 02:24:46 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 07B86240028 for <65536@debbugs.gnu.org>; Sat, 26 Aug 2023 08:24:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1693031073; bh=FtdmYtsgRpyGmCbgnpfi6UzGuX6HD9Luah9MNvjZe5U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=DaTSzRiwViRuh5Ch4erIrpm4hYX1GTyxNrOqS1rSC2TCLn1KJfGamF621HJ8wSgIO mOuAVBmFanOBKkUqilZFgBCm/yiKIOwZkfYyZvVlpHR8Hjn78zwRZo5muYVvA7TKn8 /Gpyx0NzyW79Km0fjGYIGjPikn/l5tyktkY11uia/AJuyQHMZ4anT5dTGOlS24exVh UNiVza0wxnkQVelSdXfIRHvYKACimvCSFiNMddUDK3TAb/M/zcMjAgI0xWRWJ4ctb9 FnBaAROzieOkw+e1Q89V5tyhaQQ13TL/Gsbhn3ivUY2LtCBxPHQ5Z26L7x8+WcWXre RmG64mGJdUVaA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RXmxr1qJKz6v3j; Sat, 26 Aug 2023 08:24:32 +0200 (CEST) From: Ihor Radchenko In-Reply-To: <83il92mj20.fsf@gnu.org> References: <837cpjnr2b.fsf@gnu.org> <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> <83il92mj20.fsf@gnu.org> Date: Sat, 26 Aug 2023 06:24:55 +0000 Message-ID: <87zg2e9v7s.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 (---) Eli Zaretskii writes: >> NOTE: The convention in Elisp is that any function, except for a few >> exceptions like car/assoc/+/goto-char, can clobber the match data, >> so =E2=80=98save-match-data=E2=80=99 should normally be used to save *= your* match data >> rather than your caller=E2=80=99s match data. >>=20 >> The final decision is yours ... > > I think it's okay to leave things as they are. I can share some experience from me dropping some `save-match-data' from Org parser - I had to fight the consequences, as a lot of Org's own code implicitly assumed that match data is saved, which caused huge number of tests to fail. Fixing this was not fun, although I was able to do it because that particular function had a history modifying match data in the past and only relatively recent code additions were affected. If something like `replace-regexp-in-string' suddenly changes its behaviour (even undocumented), I expect issues in third-party code. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 08:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 65536@debbugs.gnu.org, Jens Schmidt Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.169303924419350 (code B ref 65536); Sat, 26 Aug 2023 08:41:02 +0000 Received: (at 65536) by debbugs.gnu.org; 26 Aug 2023 08:40:44 +0000 Received: from localhost ([127.0.0.1]:41718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZoqZ-000521-MQ for submit@debbugs.gnu.org; Sat, 26 Aug 2023 04:40:43 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:61614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZoqX-00051j-2S for 65536@debbugs.gnu.org; Sat, 26 Aug 2023 04:40:41 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4ff09632194so2570137e87.2 for <65536@debbugs.gnu.org>; Sat, 26 Aug 2023 01:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693039230; x=1693644030; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zZVTTL8BKp89GbF7tKYacazq7wHu2b3w2SyiDZKyMNU=; b=ZztK5M1KuiHF11dYbbsfd5liLPZz1yiYfdgsa90DEYRXbsmQ2AxVN2MkhwTvnHf/1Z d37EUOLjKqIRNdBasZLQ6dRUlcH9CJ35QZgpezCCdA5rXCo7IKrz+n4Z+gsDpsK2ZaRo K9L0f6Yt+ukq+oxjLAbX/FWdgtZTSGsv2OQ0q8tOP7WpMZGvGLrrIbxsIROywozfcriM IgE2blNjzuFQnRvWCcM6JvGp/N199QGzak5L9qtsEN7k8vYsHnHZuX5m7fJawTEn4Ok+ GRi/eVaseKeoiNm1tYNmHW6NhfLPDqNcRKBYmFH5qwUYebMPCqCcSnFaZEHOoFirUdaC zHNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693039230; x=1693644030; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zZVTTL8BKp89GbF7tKYacazq7wHu2b3w2SyiDZKyMNU=; b=gMDph/XjBi+9moTLTWxm+mzFobSOlOvhSKIz4hZ9PW88B96gVN46+av3gdD5naMogG u3nyoooMMx5lMVC2nkVw5Ufth81ZZ6WSRlT+3NawUkcewudMKx5o/yi812KTh8uuvtb3 f7PIRloe25ua0nySvRRIJlvpjJyZwPLLHxKs2M2laYXClSHN7vkYFyxO/9UBx1p2KR8Q vKL009QqblarAxbKMGQfNVOPTZfWLPXwFRj2xpJDa1F/t6KWA9JlHKDagJfIq0/mjx5Q 2AJRJJ2JHzuTaxyRF+lUexPxqsypta5jz3WF8/eWN56cD7AHGaRfD46P7LOpBeDpH5CU 3iWQ== X-Gm-Message-State: AOJu0YwfMqcfbUK6cPlk2A/pAqoAe3vbphg4WtFQ53HANNaMTu2QmHTD ouKBYvxa1oYNujex9zLI2fO5rPS2Sz2oXXfpTBM= X-Google-Smtp-Source: AGHT+IGWjXvVD2QIgDkaq2aWcHi4nH046UQLeDqa1l1iVrjQVI/aIufszl8TJYzWkB08YAZqgkvKzrx/p7GnNLNo7QQ= X-Received: by 2002:a19:7617:0:b0:4fd:fd97:a77b with SMTP id c23-20020a197617000000b004fdfd97a77bmr13621757lff.50.1693039229770; Sat, 26 Aug 2023 01:40:29 -0700 (PDT) MIME-Version: 1.0 References: <837cpjnr2b.fsf@gnu.org> <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> <83il92mj20.fsf@gnu.org> In-Reply-To: <83il92mj20.fsf@gnu.org> From: Stefan Kangas Date: Sat, 26 Aug 2023 10:40:18 +0200 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: > I think it's okay to leave things as they are. > > Stefan, WDYT? We do not want to change replace-regexp-in-string's behavior. This goes without saying IMO, and needs no documentation changes. I also see nothing highly surprising or unusual about it saving match data. Interested users can easily read the code to see if it does, just like Jens did. So I also think it's fine not to change anything here, on balance. From unknown Sat Jun 21 05:19:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 09:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Kangas Cc: 65536@debbugs.gnu.org, jschmidt4gnu@vodafonemail.de Received: via spool by 65536-submit@debbugs.gnu.org id=B65536.169304098523295 (code B ref 65536); Sat, 26 Aug 2023 09:10:01 +0000 Received: (at 65536) by debbugs.gnu.org; 26 Aug 2023 09:09:45 +0000 Received: from localhost ([127.0.0.1]:41749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZpIe-00063f-V4 for submit@debbugs.gnu.org; Sat, 26 Aug 2023 05:09:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZpIZ-000639-TG; Sat, 26 Aug 2023 05:09:43 -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 1qZpIO-0007EN-RX; Sat, 26 Aug 2023 05:09:28 -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=wbwKO9ENBoB1SLC2meEbE5ouQO6RdudSTPX7NbyAKj0=; b=LPaW5jwYCNzQ yEDujN/6ryx7T7Ay7W5oAh6yK1zOEm8TlHwM6h9BP87QqfXKha0EEvFCyjt8GLODUPDfbopqLDjAN rcBQ+Omg/Q/9d7E6EoD+Q+1VDG79yzeJhtDfWxuxqSe1u5WCcHBBgHd9nF9HX1rfoGoyKFHkTy2/o e3UUtlfUYZCJArUT9PyZ01MqcycThjPEf4aSUJ0GsXa7p2xJZ6jQwNbKJwGBXbZtRRvIlVVKgvBXs tAb8MtniCPSyrJxgU9j4MAvnQ8I9FyVIVko+mgmHWSPnRcBlB849OHEDTAEOHXd1Qh2fYkw0mEn/U M96uCO6zt8n8gerVEnM9sQ==; Date: Sat, 26 Aug 2023 12:09:57 +0300 Message-Id: <83r0nqkw4a.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Stefan Kangas on Sat, 26 Aug 2023 10:40:18 +0200) References: <837cpjnr2b.fsf@gnu.org> <8e1911a9-1944-c018-f108-fb34323b361f@vodafonemail.de> <83il92mj20.fsf@gnu.org> 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 (---) tags 65536 notabug wontfix close 65536 thanks > From: Stefan Kangas > Date: Sat, 26 Aug 2023 10:40:18 +0200 > Cc: Jens Schmidt , 65536@debbugs.gnu.org > > Eli Zaretskii writes: > > > I think it's okay to leave things as they are. > > > > Stefan, WDYT? > > We do not want to change replace-regexp-in-string's behavior. This > goes without saying IMO, and needs no documentation changes. > > I also see nothing highly surprising or unusual about it saving match > data. Interested users can easily read the code to see if it does, > just like Jens did. > > So I also think it's fine not to change anything here, on balance. Thanks, so I'm closing this bug.