From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#41445: 26.3; Query-replace triggers "match data clobbered by..." Date: Sat, 23 May 2020 09:36:03 -0400 Message-ID: References: <83367s4427.fsf@gnu.org> <370FA0D9-1EF2-4EC4-977C-C20106CF222D@acm.org> <83wo542mwz.fsf@gnu.org> <76CFF420-CB1C-464A-A67C-22D813C00EB8@acm.org> <83tv06zvgl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="130842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , ture@turepalsson.se, 41445@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 23 15:37:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jcUKs-000XwA-9T for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 May 2020 15:37:10 +0200 Original-Received: from localhost ([::1]:38538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcUKr-0005Df-4s for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 May 2020 09:37:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcUKj-0005Bk-Uh for bug-gnu-emacs@gnu.org; Sat, 23 May 2020 09:37:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcUKj-0007Ij-M2 for bug-gnu-emacs@gnu.org; Sat, 23 May 2020 09:37:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jcUKj-0006dz-Ic for bug-gnu-emacs@gnu.org; Sat, 23 May 2020 09:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 May 2020 13:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41445 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41445-submit@debbugs.gnu.org id=B41445.159024097325478 (code B ref 41445); Sat, 23 May 2020 13:37:01 +0000 Original-Received: (at 41445) by debbugs.gnu.org; 23 May 2020 13:36:13 +0000 Original-Received: from localhost ([127.0.0.1]:33714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcUJw-0006cr-Og for submit@debbugs.gnu.org; Sat, 23 May 2020 09:36:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28566) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jcUJu-0006cd-Pq for 41445@debbugs.gnu.org; Sat, 23 May 2020 09:36:11 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 26C044407E1; Sat, 23 May 2020 09:36:05 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2516C4407A5; Sat, 23 May 2020 09:36:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1590240964; bh=H9HtolCGLJBu44dCqxU5+78hUC+5PB6Lz1uiszC+xok=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=KPc2ckBnvI+UOBSHspkV8EfDjKwo/KhTw+EbElrnfReLVQJVYeiWDOCVRa0xsQe4n +lbFR8Y9bI64UQZaveOnYgBQ1q2F4GnDwR9wU5xlKEQuHBaN3K4EKMeduvEQocSHTN fp8m5fy6JEgCFgWpDxVibgUy0XVEC66t5lbksPEjGdijnotdzE4nYsxxgKOlITn9GM hrRVKZnp779N2GznYMDxnxaKSq9SXzKRLrD3wIN1F/7c3FfhjeEXHoDRnjv/hg48WS YR7+rkPU204LRXWBzi8VcinVl5h3mfjduXslSJdB51dq0yFsiBgjuihpcKCyGB3dn4 M1kwCyBdWhGCQ== Original-Received: from alfajor (unknown [216.154.27.250]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ACECE1201F4; Sat, 23 May 2020 09:36:03 -0400 (EDT) In-Reply-To: <83tv06zvgl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 May 2020 15:28:42 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180802 Archived-At: >> > The advantage of not doing this unconditionally is that we don't >> > unnecessarily punishing callers that don't need match-data to be >> > saved. >> >> For callers of the ucs-normalize- functions, correctness should come >> first; their names, semantics or descriptions do not lead the user to >> suspect them of clobbering the match data. It is an implementation leakage >> which can be quite unexpected, as is witnessed by this bug. > > I thought we had some advice to Lisp programs not to assume that > match-data will be preserved, but maybe I'm misremembering. Stefan, > do you remember something along these lines? Right, we follow a convention where, by default, any function can clobber the match-data, with just some exceptions (typically, small/trivial functions). >From that point of view, I see no reason why ucs-normalize-* should be careful to preserve the match data. This said, *if* it is the case that many/most calls to a given function need to preserve the match-data around calls to it, it's of course OK to simply move the match-data-saving into that function, especially if that function's work dwarfs that of save-match-data. I just added the following to `save-match-data`'s docstring, to try and clarify: 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. -- Stefan