From unknown Fri Aug 15 01:54:43 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#73018 <73018@debbugs.gnu.org> To: bug#73018 <73018@debbugs.gnu.org> Subject: Status: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer Reply-To: bug#73018 <73018@debbugs.gnu.org> Date: Fri, 15 Aug 2025 08:54:43 +0000 retitle 73018 31.0.50; wdired + replace-regexp only modifies the visible po= rtion of the buffer reassign 73018 emacs submitter 73018 Madhu severity 73018 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 22:37:01 2024 Received: (at submit) by debbugs.gnu.org; 4 Sep 2024 02:37:01 +0000 Received: from localhost ([127.0.0.1]:33042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slftF-0008Gh-9f for submit@debbugs.gnu.org; Tue, 03 Sep 2024 22:37:01 -0400 Received: from lists.gnu.org ([209.51.188.17]:48928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slftC-0008GU-LX for submit@debbugs.gnu.org; Tue, 03 Sep 2024 22:37:00 -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 1slfq2-0004sV-UH for bug-gnu-emacs@gnu.org; Tue, 03 Sep 2024 22:33:44 -0400 Received: from smtp0.ctinetworks.com ([205.166.61.207]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slfq0-00009L-Jm for bug-gnu-emacs@gnu.org; Tue, 03 Sep 2024 22:33:42 -0400 Received: from localhost (unknown [117.254.36.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 0BD05306F085 for ; Tue, 3 Sep 2024 22:33:25 -0400 (EDT) Date: Wed, 04 Sep 2024 08:03:21 +0530 (IST) Message-Id: <20240904.080321.1100373523429404965.enometh@meer.net> To: bug-gnu-emacs@gnu.org Subject: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer From: Madhu X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Sep__4_08_03_21_2024_038)--" Content-Transfer-Encoding: 7bit X-ctinetworks-Information: Please contact the ISP for more information X-ctinetworks-MailScanner-ID: 0BD05306F085.AEE43 X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-SpamCheck: X-ctinetworks-Watermark: 1726281211.95758@DiWQvU5ttnxYeJSBIbi/QQ Received-SPF: pass client-ip=205.166.61.207; envelope-from=enometh@meer.net; helo=smtp0.ctinetworks.com 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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.4 (--) ----Next_Part(Wed_Sep__4_08_03_21_2024_038)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit In GNU Emacs 31.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0, Xaw3d scroll bars) Repository revision: f1e29506822739208e5706b733cfd713c5f37cfd Ref: https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00071.html On carrying out the following steps ``` mkdir /dev/shm/test-foo -pv for i in $(seq 1 40); do ln -sv /foo/$i /dev/shm/test-foo; done (dired "/dev/shm/test-foo") (wdired-change-to-wdired-mode) (replace-regexp "foo" "bar") ``` It is seen that only the files in the visible portion of the buffer are affeceted by the replace-regexp. The attached patch implements the suggestion in https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00079.html and appears to fix the problem. (However there still seems to be a boostrap related problem with "Match data clobbered by buffer modification hooks" when wdired is first loaded) ----Next_Part(Wed_Sep__4_08_03_21_2024_038)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-lisp-wdired.el-wdired-change-to-wdired-mode-call-fon.patch" >From 05c8405a30a36098c55e4f31a1ec339719ccbcb3 Mon Sep 17 00:00:00 2001 From: Madhu Date: Wed, 4 Sep 2024 06:55:44 +0530 Subject: [PATCH] * lisp/wdired.el: (wdired-change-to-wdired-mode): call font-lock-ensure so replace-regexp with wdired-search-replace-filenames t works on the whole buffer. --- lisp/wdired.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/wdired.el b/lisp/wdired.el index 4b6a9c14b20..dd8b8640a89 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -264,6 +264,7 @@ wdired-change-to-wdired-mode ;; hidden partly, so we remove filename invisibility spec ;; temporarily to ensure filenames are visible for editing. (dired-filename-update-invisibility-spec) + (font-lock-ensure) (run-mode-hooks 'wdired-mode-hook) (message "%s" (substitute-command-keys "Press \\[wdired-finish-edit] when finished \ -- 2.46.0.27.gfa3b914457 ----Next_Part(Wed_Sep__4_08_03_21_2024_038)---- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 23:26:15 2024 Received: (at 73018) by debbugs.gnu.org; 4 Sep 2024 03:26:15 +0000 Received: from localhost ([127.0.0.1]:33067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slges-0001Ec-Ns for submit@debbugs.gnu.org; Tue, 03 Sep 2024 23:26:15 -0400 Received: from mout.web.de ([212.227.17.11]:55483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slgep-0001EH-Gg for 73018@debbugs.gnu.org; Tue, 03 Sep 2024 23:26:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725420297; x=1726025097; i=michael_heerdegen@web.de; bh=mrXllLswA0r4MIyhy4ruGGkqmLKh/x5OINvOSqHqcps=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=XrIxHzJqssjz+wJF/k8eEFIHG0O4/WzsxI1F0euv+qVYxwrHwX1r4KauiXIoFobn AVFT4k7L99T7TS+yOlQfhZ5flDDtJeirISgPHOwE00CODmG2M7MAStmoQpTbgDIgS kvH2536wUhd8aEazIxom0fUYJYD7VRZPcHYRMPldgOTd1qhRVZCBRr2QeD7MXEdBs JygQDDZ5W38uy+kKQpb7ebAny+AHoHnNpmjX1YqWQ5wVvUz1mEBtBSmV6W0KIMbSw AsUlCrTIx5mBCO+ULn07Z30+x5cxink536YNoYisBdaxYNRVHtUL66QPkEawaO5qT 33HxyUNGh9uETCOGtQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mm9Zi-1sLBaj2h04-00f3hR; Wed, 04 Sep 2024 05:24:57 +0200 From: Michael Heerdegen To: Madhu Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <20240904.080321.1100373523429404965.enometh@meer.net> (Madhu's message of "Wed, 04 Sep 2024 08:03:21 +0530 (IST)") References: <20240904.080321.1100373523429404965.enometh@meer.net> X-Debbugs-Cc: Juri Linkov Date: Wed, 04 Sep 2024 05:25:46 +0200 Message-ID: <87seug85hh.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:WZuB9IpwJFMtWqBgvIuIfQEhiI2VVUPI7whRCPEDG0xdfd+FRJW Q1C5o8YVVAqRTU8TzRk5ttZdkKcpyMGUlcfDYSJblHQLROoqYeASndnAXTLyIkfzSFbG9oN cyjUuC0Q5twQH0ToekP9J2icu0YjtlArfm77pD54lDU7j36hnAcGaBShr09MMDHOy8RPBIA L4v8nBwOjziM2p29YFOWQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:kRwIVnAPJKA=;ErzHYuISDYTfgkhIAPr4UD5Q68t 238iMwjpxm/oN8qiO2NQPajxp3JB/IMU0oU1UHrCxiv9GISgBKGkprBkZnXmDicREbKcjVQtp a3pqyEw9jVXge/7bLCPMefVmBxBKHKKjo+sHeMP7KMZE96JzdW9MiRUUw7Zo6gvFwXPJot38E XS+IQ/OeF4N2UemICwI1h7TEKjk0j5WC8ePiHmGaCkStsLOnuDabWEUzFE4wInZt62SlpV7yu oDSNuMMsCqVOJo5UlWZeAWdjEHosBE8mbHgOZiMjCrdIiXBqg2KgnvqXuf0heUu5yO7KNEWyw hlMU+C6bIJUUgeaTfeCoSzVQ6gLrteQJUJtabILrwjczcXA+jQ6EmPPbt8FpCkUeIFt12Dgvc lWYXFHY0a+CmhKIWqRhuiEUQeziAoVRaB50nwL2R8kFmdOclEi3VuG2aBeuz2pz/KECsuInhA f7eawGR04BcI+Twvs8DPNguvIPNWEBucCW+Au7WYqqvuZdsOF/ypRFNrRnSf6InS4Bb6d3xzI EJwuqpOt5CIPK28AmqBqw01NR4pHIlZGAH5mVTRsSLAVC62b0TpNFBiZH1jwlAuDtaWtjKUAy k2dyC3Q9mO8HU6E2rRHE5mgRXEHZpZiq42v4vtoM0ly7xTzMF72v6WeHHnIZ3gJ57GobWuwg7 c2YOxnlIFl9iLgrNRTLi6UDbWsNvSxQUJEVMGCKhLl54ea0R3nuEKhbEueK0IVvVPj1Jkkier x+cGNP/dzlkc0QWTnZxluu0KqmrQUeJ6QPko5vJX46yo0dvRPJEep2/+SiypseKuodc77aHE+ 0KeVbNgBRzk3Z59rRDr+k0Qw== X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: 73018@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 (-) Madhu writes: > (dired "/dev/shm/test-foo") > (wdired-change-to-wdired-mode) > (replace-regexp "foo" "bar") > ``` > > It is seen that only the files in the visible portion of the buffer > are affeceted by the replace-regexp. The attached patch implements the > suggestion in > https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00079.html > and appears to fix the problem. Thanks for reporting this here. I CC Juri Linkov. > (However there still seems to be a boostrap related problem with > "Match data clobbered by buffer modification hooks" when wdired is > first loaded) Could you please post a recipe and a backtrace for this second problem? > --- > lisp/wdired.el | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lisp/wdired.el b/lisp/wdired.el > index 4b6a9c14b20..dd8b8640a89 100644 > --- a/lisp/wdired.el > +++ b/lisp/wdired.el > @@ -264,6 +264,7 @@ wdired-change-to-wdired-mode > ;; hidden partly, so we remove filename invisibility spec > ;; temporarily to ensure filenames are visible for editing. > (dired-filename-update-invisibility-spec) > + (font-lock-ensure) > (run-mode-hooks 'wdired-mode-hook) > (message "%s" (substitute-command-keys > "Press \\[wdired-finish-edit] when finished \ Yip. When we do this (guess we don't have a choice), my preferred solution would be to hook this into the corresponding isearch function. Because calling `font-lock-ensure' can be really slow in large dired buffers (several seconds). Or we manage to rewrite things so that the work is done on the fly in some way. Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 04 05:01:44 2024 Received: (at 73018) by debbugs.gnu.org; 4 Sep 2024 09:01:44 +0000 Received: from localhost ([127.0.0.1]:33483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slltX-0002KY-V5 for submit@debbugs.gnu.org; Wed, 04 Sep 2024 05:01:44 -0400 Received: from smtp0.ctinetworks.com ([205.166.61.207]:39738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slltV-0002KI-4L for 73018@debbugs.gnu.org; Wed, 04 Sep 2024 05:01:42 -0400 Received: from localhost (unknown [117.254.37.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id C2D59306F085; Wed, 4 Sep 2024 05:00:27 -0400 (EDT) Date: Wed, 04 Sep 2024 14:28:31 +0530 (IST) Message-Id: <20240904.142831.1583368143272051709.enometh@meer.net> To: michael_heerdegen@web.de Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer From: Madhu In-Reply-To: <87seug85hh.fsf@web.de> References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Sep__4_14_28_31_2024_624)--" Content-Transfer-Encoding: 7bit X-ctinetworks-Information: Please contact the ISP for more information X-ctinetworks-MailScanner-ID: C2D59306F085.A1CBA X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-SpamCheck: X-ctinetworks-Watermark: 1726304431.8639@uXd9Iz9XIH3x6lsiUPiZ+Q X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: 73018@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 (-) ----Next_Part(Wed_Sep__4_14_28_31_2024_624)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit No problem, * Michael Heerdegen <87seug85hh.fsf@web.de> Wrote on Wed, 04 Sep 2024 05:25:46 +0200 > Could you please post a recipe and a backtrace for this second problem? ``` emacs -Q -l f.el ``` produces the backtrace in the file backtrace.txt with the match-data clobbered error. At this point (i.e. after the error occurs) if I do "M-x load-library wdired", then a subsequent replace-regexp operation succeeds. However in a long running emacs I believe I still see the match-data clobbered error crops up again, I'm keeping a lookout on what might be triggering that. ----Next_Part(Wed_Sep__4_14_28_31_2024_624)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="backtrace.txt" Debugger entered--Lisp error: (error "Match data clobbered by buffer modification hooks") replace-match("bar" nil nil) replace-match-maybe-edit("bar" nil nil nil (170 173 #) nil) perform-replace("foo" "bar" nil t nil nil nil nil nil nil nil) replace-regexp("foo" "bar") eval-buffer(# nil "/dev/shm/f.el" nil t) ; Reading at buffer position 359 load-with-code-conversion("/dev/shm/f.el" "/dev/shm/f.el" nil t) load("/dev/shm/f.el" nil t) command-line-1(("-l" "/dev/shm/f.el")) command-line() normal-top-level() ----Next_Part(Wed_Sep__4_14_28_31_2024_624)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="f.el" (setq $test-foo-dir "/tmp/test-foo/") (ignore-errors (make-directory $test-foo-dir)) (ignore-errors (loop for i below 40 for target = (format "/foo/%d" i) for link-name = (format "%s%d" $test-foo-dir i) do (make-symbolic-link target link-name))) (dired $test-foo-dir) (wdired-change-to-wdired-mode) (load-library "wdired") (toggle-debug-on-error t) (replace-regexp "foo" "bar") ----Next_Part(Wed_Sep__4_14_28_31_2024_624)---- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 04 05:10:07 2024 Received: (at 73018) by debbugs.gnu.org; 4 Sep 2024 09:10:07 +0000 Received: from localhost ([127.0.0.1]:33507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slm1f-0002Yd-3M for submit@debbugs.gnu.org; Wed, 04 Sep 2024 05:10:07 -0400 Received: from smtp7.ctinetworks.com ([205.166.61.237]:54536) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slm1d-0002YV-Gf for 73018@debbugs.gnu.org; Wed, 04 Sep 2024 05:10:06 -0400 Received: from localhost (unknown [117.254.37.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp7.ctinetworks.com (Postfix) with ESMTPSA id CADC21272BB; Wed, 4 Sep 2024 05:08:57 -0400 (EDT) Date: Wed, 04 Sep 2024 14:38:48 +0530 (IST) Message-Id: <20240904.143848.1990984592984376220.enometh@meer.net> To: michael_heerdegen@web.de Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer From: Madhu In-Reply-To: <20240904.142831.1583368143272051709.enometh@meer.net> References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <20240904.142831.1583368143272051709.enometh@meer.net> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ctinetworks-Information: Please contact the ISP for more information X-ctinetworks-MailScanner-ID: CADC21272BB.A80F1 X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-SpamCheck: X-ctinetworks-Watermark: 1726304941.12717@4/38SacotUZMV5gLKswXtQ X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: 73018@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 (-) * Madhu <20240904.142831.1583368143272051709.enometh@meer.net> Wrote on Wed, 04 Sep 2024 14:28:31 +0530 (IST) > produces the backtrace in the file backtrace.txt with the match-data > clobbered error. At this point (i.e. after the error occurs) if I do > "M-x load-library wdired", then a subsequent replace-regexp operation > succeeds. However in a long running emacs I believe I still see the > match-data clobbered error crops up again, I'm keeping a lookout on > what might be triggering that. I think this error goes away with an ;;;###autoload cookie for wdired--before-change-fn in wdired.el (The actual sequence of events is obscure) From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 04 12:16:11 2024 Received: (at 73018) by debbugs.gnu.org; 4 Sep 2024 16:16:11 +0000 Received: from localhost ([127.0.0.1]:35195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slsfy-0006Ph-Px for submit@debbugs.gnu.org; Wed, 04 Sep 2024 12:16:11 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:60343) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slsfw-0006PD-Me for 73018@debbugs.gnu.org; Wed, 04 Sep 2024 12:16:09 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id A44EF1C0005; Wed, 4 Sep 2024 16:14:57 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87seug85hh.fsf@web.de> (Michael Heerdegen's message of "Wed, 04 Sep 2024 05:25:46 +0200") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> Date: Wed, 04 Sep 2024 19:13:31 +0300 Message-ID: <86y147gzx0.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) >> + (font-lock-ensure) >> (run-mode-hooks 'wdired-mode-hook) >> (message "%s" (substitute-command-keys >> "Press \\[wdired-finish-edit] when finished \ > > Yip. When we do this (guess we don't have a choice), my preferred > solution would be to hook this into the corresponding isearch function. > Because calling `font-lock-ensure' can be really slow in large dired > buffers (several seconds). Or we manage to rewrite things so that the > work is done on the fly in some way. So you prefer to slow down only when the user types C-s? This is possible by adding a local hook in wdired-change-to-wdired-mode: (add-hook 'isearch-mode-hook #'font-lock-ensure nil t) From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 05 08:12:56 2024 Received: (at 73018) by debbugs.gnu.org; 5 Sep 2024 12:12:56 +0000 Received: from localhost ([127.0.0.1]:36325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smBM7-0003bn-R9 for submit@debbugs.gnu.org; Thu, 05 Sep 2024 08:12:56 -0400 Received: from mout.web.de ([212.227.17.11]:50289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smBM5-0003bR-QX for 73018@debbugs.gnu.org; Thu, 05 Sep 2024 08:12:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725538292; x=1726143092; i=michael_heerdegen@web.de; bh=sCNmEKsy/uHikEM1yOJvPfgrl7zTIYvo0LudtDK3/xY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=p21OnatTDXxqEEk8l6QsEvPPTspo9mvjCloS+T4kLwq/AQSKVa3xA3oI1iWUYjcs /u2b57TyWUq+tCl90LmpZPJ+PulpApdJGl8jh48y2G1AAQDiK9xLqxuHeD/UZCVLN t/OBr3VdDSCjA64sm0LAf5E/a1qoCP4a0iM0XsmZjFCZalyULIKzsj2qtS5WGrDKj KmPGAQaA3kZFLXDE1tEl8q3c9nhQRtxJVaEuM2Zog6qQACvzpCyBFO6HX/qNC29GT LANm20RG8Ip7Su1w65kxt94WKbenvGa8gbpts2sVyT9ULD5vQlFDJ0O/oKwoACClz HQ4wVmnWXYtMuvpn+A== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N7QUJ-1ryLMH08ir-0177of; Thu, 05 Sep 2024 14:11:32 +0200 From: Michael Heerdegen To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86y147gzx0.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 04 Sep 2024 19:13:31 +0300") References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> Date: Thu, 05 Sep 2024 14:12:19 +0200 Message-ID: <874j6uz4d8.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:N8H0xpnm/a/yI3CsmcCkyE7JzhD52At5NkBkJInu5hCE/D0Dg+d GUWaAQgoHqunn0oDWTY17aYbKGVIQSIZn7b+qNqBiQNAIaTXAJEFHMq/as0xl8+tV9ocCyD Uzu9mH5lwbdImR7YSla3Zbp50YJnrnEYp6/GvLy84VY7x5A6NXbnOsD7vlGZ82bZGxeFvQq Hr/1zxCn5kyiP1nHOdqaQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rRMiVAlkSTE=;cW7BrV9MiaAb7PfAKBzBAspBpUS p258FcPEyxiXADYTM0GlsgAGU29WrnYFqT2ubbXNCGrV/cgsTAciFL5Magz04gkYKzfrIC22H xCDQZ3FxqCGt8Mwo42pZxJ5IUKoyQeOSAtJ5zjvak870KoFmE8kalxQmb/EijDtCxwrF7J+76 8JotMBshdjnzrz8oV+L1WWImIb6/v5nh3/L7MnRmdH5OcKgtvN2YdATTM5/QE+Sg1DgM4YGoR GCsZPzWHPrTuus93pPysbHmbqkpGiQJ3Lu3w2IpxU4yuM87aiK03Uui3D6rqJKzoInhGLhnD7 eZMd0pDJKbce0YKdRI3WsqK2ocC7kjboo/mUajAGwUOqAwdScHVDa3EnMokCiHqlEo50xiJjv 3C9CZZ0wD8pfKFvTUduf6+vsqbsVX5R9xdnSbrLgxqVx5PRf4urDSwzq1aeTImiPFRNDRdrMR JJ0i/pjrOcjR5F5oT7uEghkzfCvCQAmdUOJ7KmnTMZRnCaS5RBBmUBSjtrUW1S7dIvtCns94P HnP3vuBF2zxS8YEEkaBV6nSCZtp2OfbHTgOPgSjqrt7xvsv/7eEGw/3dD/5J55IP6/mWzGyQp Vg5qayaFxr7tZn+RQlXkF0thGgd8hKeDgbIcy0PsJW+8rB7kYpCRs7uzC+sUKquxT45G5weGZ UY4u6pEVFJsHP+yb0j7majbl1S6/GExDNqyVHJWwBk4Q80UvBIDoYD6nwJvk3eBfjdn8d76Qw QiJ+V/DT8wO901DX4YP3AmAxGQYwddAMp/QkWhXG1SNl3pLGIIVKijDh+gGkde3OsnYfopeXp 6pMY/EdkzgOAkUOhISCvRfBQ== X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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 (-) Juri Linkov writes: > So you prefer to slow down only when the user types C-s? > This is possible by adding a local hook in > wdired-change-to-wdired-mode: > > (add-hook 'isearch-mode-hook #'font-lock-ensure nil t) A step back: I now tried to reproduce the recipe, but I only see the clobbered match data error (randomly) - I don't see only the visible buffer portion operated on. With other words: I can't reproduce the issue, at least not with the "visible buffer portion" interpretation, and I don't see that we would need to call `font-lock-ensure' at all. Second: I'm confused. Apparently, when `dired-isearch-filenames-mode' is on, why do `search-forward-regexp' and `replace-regexp' behave differently? `search-forward-regexp' does find matches outside of file names that `replace-regexp' ignores. Michael. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 05 12:53:03 2024 Received: (at 73018) by debbugs.gnu.org; 5 Sep 2024 16:53:03 +0000 Received: from localhost ([127.0.0.1]:38043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFjD-0008Ta-AA for submit@debbugs.gnu.org; Thu, 05 Sep 2024 12:53:03 -0400 Received: from smtp0.ctinetworks.com ([205.166.61.207]:48260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFjB-0008Sm-Gh for 73018@debbugs.gnu.org; Thu, 05 Sep 2024 12:53:02 -0400 Received: from localhost (unknown [117.254.36.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id A4B24306E67C; Thu, 5 Sep 2024 12:51:45 -0400 (EDT) Date: Thu, 05 Sep 2024 22:21:40 +0530 (IST) Message-Id: <20240905.222140.1963443907023604984.enometh@meer.net> To: michael_heerdegen@web.de Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer From: Madhu In-Reply-To: <874j6uz4d8.fsf@web.de> References: <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ctinetworks-Information: Please contact the ISP for more information X-ctinetworks-MailScanner-ID: A4B24306E67C.A1A71 X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-SpamCheck: X-ctinetworks-Watermark: 1726419110.29394@CRVqda3aBCmQJKQre8O9tw X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: 73018@debbugs.gnu.org, 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: -1.0 (-) * Michael Heerdegen <874j6uz4d8.fsf@web.de> Wrote on Thu, 05 Sep 2024 14:12:19 +0200 apparently the autoload cookie fix that i suggested to wdired.el wdired--before-change-fn (and recompiling) only gets rid of the match data clobbered error when I have already applied the earlier font-lock-ensure patch. also the recipe is flawed, I apologize. [i didn't (require 'cl-lib) which is required for emacs -Q] But if you are in a dired buffer looking at /tmp/test-foo with 40 entries of symlinks of the form n -> foo/n This is the behaviour I get on emacs -q: 1. C-x C-q 2. M-x rep-reg "foo" "bar" RET ;; get a match data clobbered error (q), C-c C-k to revert dired 3. M-x load-library "dired" RET ;;makes the match-data clobbered error go away 4. C-x C-q 5. M-x rep-reg "foo" "bar" RET I get "Replaced 19 occurrences" and the point ends up on the last entry, the remaining entries have not been replaced. I confirmed this twice before posting From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 05 13:05:48 2024 Received: (at 73018) by debbugs.gnu.org; 5 Sep 2024 17:05:48 +0000 Received: from localhost ([127.0.0.1]:38137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFvY-00012r-4a for submit@debbugs.gnu.org; Thu, 05 Sep 2024 13:05:48 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:49915) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFvV-00012Y-F0 for 73018@debbugs.gnu.org; Thu, 05 Sep 2024 13:05:45 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id AD3431C0002; Thu, 5 Sep 2024 17:04:32 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <874j6uz4d8.fsf@web.de> (Michael Heerdegen's message of "Thu, 05 Sep 2024 14:12:19 +0200") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> Date: Thu, 05 Sep 2024 19:51:48 +0300 Message-ID: <86ed5yujq3.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) >> So you prefer to slow down only when the user types C-s? >> This is possible by adding a local hook in >> wdired-change-to-wdired-mode: >> >> (add-hook 'isearch-mode-hook #'font-lock-ensure nil t) > > A step back: I now tried to reproduce the recipe, but I only see the > clobbered match data error (randomly) - I don't see only the visible > buffer portion operated on. With other words: I can't reproduce the > issue, at least not with the "visible buffer portion" interpretation, > and I don't see that we would need to call `font-lock-ensure' at all. Maybe this is reproducible only on very long Dired buffers? > Second: I'm confused. Apparently, when `dired-isearch-filenames-mode' > is on, why do `search-forward-regexp' and `replace-regexp' behave > differently? `search-forward-regexp' does find matches outside of file > names that `replace-regexp' ignores. `replace-regexp' uses Isearch functions, `search-forward-regexp' is a core function that doesn't use Isearch. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 06 08:04:30 2024 Received: (at 73018) by debbugs.gnu.org; 6 Sep 2024 12:04:30 +0000 Received: from localhost ([127.0.0.1]:52377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smXhV-0002Ov-OS for submit@debbugs.gnu.org; Fri, 06 Sep 2024 08:04:30 -0400 Received: from mout.web.de ([212.227.15.14]:37697) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smXhT-0002Og-MA for 73018@debbugs.gnu.org; Fri, 06 Sep 2024 08:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725624252; x=1726229052; i=michael_heerdegen@web.de; bh=XTbUt5+rzr2MYs56IWNL6bTrfgl3TDUd8eNENFr0J1c=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=JhWMsj2T7BHKMEzGsEFTkZRPSEK23m9HKgc3apWVNsXWWuSRzG6zkXBPCui89Kbi g4J8/86vS/Gy2UvvJFNWL3NoaoyUm83Bzm5SyceU5slXYnl9FzdblyccRDAZgAZb0 CafbsIiHE+9pwmrM6pFxjeGpr+pQL0yde7svKmealvmQv9YDAkjcYYTdlH9GMGsjx /R8X/dSu8tjvecnWHn1X/7voPifK+BWRZEAXz0tUBVNbqpf22sgryKFKxqH8ZL81g Sd/bknNSpiFRHErmOhE5lbe1Ige194/fBEK4Sf3yTzm3N0B9dBN0RNLyEP7br1AJl xqv4X3+gCPKtQEpYUQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MnG2C-1sN4ES2S5E-00hvRw; Fri, 06 Sep 2024 14:04:12 +0200 From: Michael Heerdegen To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86ed5yujq3.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 05 Sep 2024 19:51:48 +0300") References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> Date: Fri, 06 Sep 2024 14:04:58 +0200 Message-ID: <87v7z9rnrp.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:FH7WjSo/JBY2hXqcju3Aph5olqI85AbAej3uHLmhqLcv2L4cxaM +gGHTKt5U6Rs471Q+1T7TYKpjuVKqiiCUkHYo3Nvp7yHzpYmOrXmO1Zp9vpj8sHz/3v0vnJ OUl/52c6pOnyYAUQ35dMXvV9IAdLIe7LsdATEB6glWRqBAOJ5UTz4QDUSAsFOnjGi+83+jU EN7JKgh7tTo7ohmAH/aow== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Z/qmEfFNfMs=;P03kvg75t3kiMcgL5q0C7JgNPAz 7CPLde6SZ4lJt47MEbFWL8pcaw8dfDLxGVXrC/Xxj6qZ8DYhjQPwplTMUsoQoy6nUc7+zUyNO Olf2F5PNAz2mkYTUYg9GGxJjeBnBybthihTyqKPvjCIhy+DLqFDDjQRH9kimYE1wkXjZBdNG/ /pjgz05Lxa9oULXENUOy2jbcPUB1xgo0KP4wbkECUOZ5oz/0dOGdyq5Ohx4XQoKAti36z1faH uXcuiRL5aqrpUju3CFcU4yYmICjEWrMm9MEXDklNk82qKucyRCi0LVDMIMTabeJ5o2PXQ69P6 9RJHzCwRNUspKYC38u9Zbsji4STT1eYMKZ2INzaVurC6uJEeMLd9vmrh10Fko+uDslNe0Pc55 4YeQ0pB+Z00kJplfyhYNyP2a/2q4EQofXM967E1Wop91+sCR8dJ6khfa7QZz6piLPfyHIvASB d3NPzyw4Vkw3tM8kltcfDegYraWFbmcGSF3MggiJzteyGvq/79JhGQK8dHf4DUPZnS08Tnsis QydCoxzp0OJcVSA0NXQDSij77aHzwL4sMBCs2C9wT1xMSnmhjNAV5vci5vXOSp8I/iKnxP0DV mWYBHkYv95C1lpYWaMAQ5JwXBIUkPFKpNfxrI/Qyocsr4yV3NLJKoLSMh90IrKljGkmi34GWj qVPCgny5e2rHo+OI67+1Jgby8QO1fO6WgYGo7ISJrMSwH5s406IkEyb+xyWDb5Wq3KGpZOIlN WZtG6oC5F6YtwsR6Gd3ONE0KiMZSOAI4VXZhDmaEX69/GYceFEpg/oZGVv1NYLmStdSkDDFKs ahCxeVoG/dlr5b5uAMmPKAeA== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) Juri Linkov writes: > Maybe this is reproducible only on very long Dired buffers? I tried in a buffer with over 19,000 files. I should have experienced a problem (no matches found, nothing changed) if font-lock would be related. But every function involved always found matches hundreds of screens below the current position. I reloaded the buffer after each experiment to be sure only the currently visited area was ever displayed. OTOH, I did see the match-data issue occur. Maybe this is the only reason of our problems. I would focus on trying to understand that problem. > > Second: I'm confused. Apparently, when `dired-isearch-filenames-mode' > > is on, why do `search-forward-regexp' and `replace-regexp' behave > > differently? `search-forward-regexp' does find matches outside of file > > names that `replace-regexp' ignores. > > `replace-regexp' uses Isearch functions, > `search-forward-regexp' is a core function that doesn't use Isearch. It's a not-so-nice inconsistency, but ok... Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 06 12:07:43 2024 Received: (at 73018) by debbugs.gnu.org; 6 Sep 2024 16:07:43 +0000 Received: from localhost ([127.0.0.1]:54017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smbUt-0008WR-53 for submit@debbugs.gnu.org; Fri, 06 Sep 2024 12:07:43 -0400 Received: from mout.web.de ([212.227.17.11]:57575) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smbUq-0008W7-LS for 73018@debbugs.gnu.org; Fri, 06 Sep 2024 12:07:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725638845; x=1726243645; i=michael_heerdegen@web.de; bh=e9LfQ6+hj9eBp/p+es9WbYh+xCyj0fC0zhpnAZKX0AI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=eJN30YweuWF8VEA/M4vZVExd47JPu2txHwUZTu6ezKmrSZvmCne8LyBg4wPl8luQ X87ho1NzXU0zNVew8kMQc2Mkuf+okV5QVfhvJ4WIXMv6WY+T02tJLl+vCeKKVNxAr lBjxAAbEM6M9y7M8pEb6mcKY7//hHKt83IkYkUy8CQ5Slj4Qld2OgthfRMEYK9Iwa 2ol8TRilP8f2dohd+I7+WFCOp9nw4IQXNKzKfcFGKUk9DpSJ14zYRcAQkPGA0dRMC um5TDyuWw3Q57dDPBbjGBawNojGHDsMjrIx82FuYWMEYYY3cPKYVauP/d4pdG5enO gDdYkqO+qf5uH+qApA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MFJjP-1soVHw1ycT-003WqN; Fri, 06 Sep 2024 18:07:25 +0200 From: Michael Heerdegen To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87v7z9rnrp.fsf@web.de> (Michael Heerdegen's message of "Fri, 06 Sep 2024 14:04:58 +0200") References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> Date: Fri, 06 Sep 2024 18:08:15 +0200 Message-ID: <87o750dats.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:JloxxU32DQrieEQ9W0CCVYqTlnEFkRJ6mqIniyDmLlYSGjZ5phZ 5CnQRWVllS4NCHpEhblAn2B4zEiIwn92p3L5UqRmiRcEfuhDBk2WduRqnse9YwhaFi2UZpM ijaPlMz3c0Xn16B2/gptGqondbMlRn9rY54w3VnJYq2yD05FfLaDqX8pUeXfCi8SpZSm9Sn 0prxK5mZLTqqF2D/mgN/Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:xO80i5MpquM=;1PXobAHg3vnFgAo0TmA94qjyBrh rLncVZzitCEHTNq22tae5LE4WkHdLFTeJu9dMSCbaRpoUQEvOt+z15APvc7mTBJvlDjXZO9Q7 ZQj8PGIol5AX5MNGvX1WsuS8GI3j0PAcM9/hyDbv/UzTdTe20JF4qYvPvrWWZNXVR7jIyvukt mM0Jt/PJPif2Ja2RR+XyRY9Qb8g5IC56yIMZJNDFE9zCsOYnqevU/8p7ROqyw4HBFU76KcIcg GjKqj7nGd7nWLgEh4O96bWjFAtoq64E9mxuzXnOy/wSAJFJIIU+T3K0BH3qENKb4kBU7fiHKA bcFXQAM5MOECHhDafi9VCWLE+vMWV+iGv3LBExKI8Oqug7n28JLNqj/kKwtp50AmgWWFh4lzD +HHVS//IvW4Kj9xn6KCN0Y6YvCUkL4d3vWkci6qIErWOd1z6nBPO7u6cU7dJfo3xFIDMYrngY qxkScVzLOIfm8UF3vIO6vTIZzOXVSPskdwEKoaaulqMN1dSg6nQGuJvYWpCsmUdvTZQDZl7B0 AW7DhXeIIVTszpOQQMXACshLdr0lA9JIkhW9dwLqZnlQzkLtTXJcrvjI1RGHYp87tqdJEDT9i Waj57Q+aQDj3+bgrWey3M5Gf68ErysBbgG4goRkiQP2VbnBzhnC0c7/yEaLMd7Zv8LvbUJR1z DqfyF2oztCBkJkx3fBw7HAo3swVMtCBsN7+HYfuS8PPc1oBCSXEGsHK2SvO2eNR2uhaieORBc nS/a3gMaXSmuOAY22uOjtWMyxLjGm0ZJt0hQuYv01LZjwTQIBtcUb5KN1RZ/tKNGW5nhByrbc KlZsRgVw4VNjJKIUbBs+tzpg== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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 (-) Michael Heerdegen writes: > > Maybe this is reproducible only on very long Dired buffers? After following the recipe literally, I could reproduce that thing, too. Maybe this issue occurring depends on what exactly is replaced - symlink targets. In this case, (font-lock-ensure) does make a difference. Yesterday I had experimented with replacing in symlink names - in that case, the whole buffer had been considered. Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 08 12:42:26 2024 Received: (at 73018) by debbugs.gnu.org; 8 Sep 2024 16:42:26 +0000 Received: from localhost ([127.0.0.1]:59940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snKzZ-0006iR-SN for submit@debbugs.gnu.org; Sun, 08 Sep 2024 12:42:26 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:44373) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snKzX-0006iB-2y for 73018@debbugs.gnu.org; Sun, 08 Sep 2024 12:42:24 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 24B0FE0002; Sun, 8 Sep 2024 16:42:11 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87o750dats.fsf@web.de> (Michael Heerdegen's message of "Fri, 06 Sep 2024 18:08:15 +0200") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> Date: Sun, 08 Sep 2024 19:28:32 +0300 Message-ID: <868qw2ruv3.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) >> > Maybe this is reproducible only on very long Dired buffers? > > After following the recipe literally, I could reproduce that thing, too. > > Maybe this issue occurring depends on what exactly is replaced - symlink > targets. In this case, (font-lock-ensure) does make a > difference. > > Yesterday I had experimented with replacing in symlink names - in that > case, the whole buffer had been considered. I tried this: (dired "/dev/char") M-: (buffer-substring (- (point-max) 2) (- (point-max) 1)) => #("7" 0 1 (fontified nil invisible dired-hide-details-link)) M-> ;; (end-of-buffer) M-: (buffer-substring (- (point-max) 2) (- (point-max) 1)) => #("7" 0 1 (face default dired-symlink-filename t fontified t invisible dired-hide-details-link)) And indeed, after going to the end of the Dired buffer the last file gets an additional property `dired-symlink-filename' used by Isearch/Replace. Also noticed that doing the first replacement always raises an error: Debugger entered--Lisp error: (error "Match data clobbered by buffer modification hooks") replace-match("!" nil nil) replace-match-maybe-edit("!" nil nil nil (672 673 #) nil) perform-replace("7" "!" t t nil nil nil nil nil nil nil) query-replace-regexp("7" "!" nil nil nil nil nil) funcall-interactively(query-replace-regexp "7" "!" nil nil nil nil nil) command-execute(query-replace-regexp) From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 09 10:55:26 2024 Received: (at 73018) by debbugs.gnu.org; 9 Sep 2024 14:55:26 +0000 Received: from localhost ([127.0.0.1]:33860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snfna-0002Rl-D7 for submit@debbugs.gnu.org; Mon, 09 Sep 2024 10:55:26 -0400 Received: from mout.web.de ([212.227.17.11]:53755) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snfnX-0002RV-H5 for 73018@debbugs.gnu.org; Mon, 09 Sep 2024 10:55:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725893708; x=1726498508; i=michael_heerdegen@web.de; bh=No1HdJHcdhzpWZ3UXOh0+mU8JnXgZ5QgfwzIctccaW4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=VTCSUw/nh3cZAoaKM2UP3KrGCfYWSpL4cFf7o4vPp2bD6TUDyJTm+uNPgviUrj78 Q6i0UYgHNHa+h1H4yDbDWf8Nc0Gkow7O4mfVWZTLM+S6WTbhBac8f5E9/ucjIAIdq ZzPAoFPTR+l0otq43jQvP4weOtFfuFszAaD0QSWDBXIcp7J2XTy8hz+IgUtci1pMS +LolLZpGcIFjVCdupWEkCnDxTnDP303tY+GcrS4Cq6U2z8ibPoaTcVaNRywsSZuzH ozy/iNTM3RpFXHfJwSsnCXmcOPrnrVx/e7MYqaFPZNRF/pUBGjukG2KYsiKKIXdRL i8btJ2GYlyUmePxN8w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N3Gki-1s5Mwo1jXu-00x8jH; Mon, 09 Sep 2024 16:55:08 +0200 From: Michael Heerdegen To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <868qw2ruv3.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 08 Sep 2024 19:28:32 +0300") References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> Date: Mon, 09 Sep 2024 16:55:59 +0200 Message-ID: <87bk0w511c.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:bFa5e+WBZ8vPIkXh6bcBQtHA6TRd3o2RjRHmp5fSIo2x/ipovp2 zLQhiJjjE2G6zDdC0BAQo1G0HLOFokSJkP5QqbFAnlciR2gNXw6Y5LxkYsnOpjEUeKbUw0g 73+fo/e0LP2cn4Dn28idHMi9reEd8dCVCkFMpd8ynKbDaH1UiIm20Auc2gnk8fOvCB1PKLv K6UOVKxTgJHX6u/KOkb9g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:l2wOQAB++Lk=;Rs22Ev2/PHULwbIZ+lLMYa4f1Z4 BgLfyFB6a5/QFWb/Qom1mBoJ/sUXele6a8FvwDnRJd8yQpHDWLvbUYk1ukLb8ZopFVQGtlxzD TYEa8A2ivXxqKmQAcvOkdY/0UA9Q3J3FZ3oUVups54dwaabayLnSpaoxEmM9lNlJk3fILxoMN eNfdxUzc2q1l8RoSRgmMc86zqzoi4RxovjNbArqfYct4o6+4cTE01eGvsQgn2j2oQ1X9VACXO aDhyG+Yc3xXVy4n+nCkWXsDKYSzrxoj3Lh/jJs7H+z+b+csRx0NTksOyg+J08IERZho1QOjWX y8IoUxh6KmY4YQtxJma6fMT1JaBs1h72swW2z4S+yAU/vhyfhgRKo25oyCrxcYmbyFv2OuHuG C7yi81b+I/pKd4TJEemyMzALGt5Q7n2FqcK6EvTv3THRM/pzZV5XRrLdpkoQg3YHidwHEWoYf K+WnPwKunJWXrb6NFawBa+r2VJ0zsV6GH2xsvSHR3GOhdyla8i36FrLLz9RJT8lpOxqZz6DYh eYmenbXhQcYfK16UZMzbVM2dCpjNsqrmLHrlW6OxoB8Ot3cx2DqCPo8/nDyCOIIksm1tq4ONZ Z7lliXQP8reOlLjQUdjki3lr8IhKx3wh+eHc+WiVS3pQbRqtTBvmOts4jwV58/rSX9SUZ8anj ZaeWSrNOcOonGsgpVONedCOAXPy4OttpHYKwcf8fL2Y8LKImTbZTyPcip0dNbhNCpIgnbC/bu pFEUGNweQl0BHIRLLj/BBTxFJDNhhtr5GCHKPzkXGHoBtHdvDat3LAK7udnPh+NYXGSV5rBjK R/UKK7UaZ6c8uuIOMxgVam0lN6ImG1HSBbeyC62P3Nkd8= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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 Juri Linkov writes: > M-: (buffer-substring (- (point-max) 2) (- (point-max) 1)) > => #("7" 0 1 (fontified nil invisible dired-hide-details-link)) > > M-> ;; (end-of-buffer) > > M-: (buffer-substring (- (point-max) 2) (- (point-max) 1)) > => #("7" 0 1 (face default dired-symlink-filename t fontified t > invisible dired-hide-details-link)) > > And indeed, after going to the end of the Dired buffer > the last file gets an additional property `dired-symlink-filename' > used by Isearch/Replace. So, the properties we use are of different types: some are already attached by `dired-insert-set-properties', others later by font-lock (see `dired-font-lock-keywords'). AFAIR this is because some tests are more expensive than others (e.g. the test whether a link is broken) and are intentionally delayed. Would something like this be good? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-WIP-Bug-73018.patch Content-Transfer-Encoding: quoted-printable =46rom c5ef8c8db7d8b2ab03998a0f3f2a1b820ff24e2a Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Mon, 9 Sep 2024 16:46:13 +0200 Subject: [PATCH] WIP: Bug#73018 =2D-- lisp/dired-aux.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d79ec342435..77dde7147bc 100644 =2D-- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -3740,8 +3740,12 @@ dired-isearch-search-filenames The returned function narrows the search to match the search string only as part of a file name enclosed by the text property `dired-filename= '. It's intended to override the default search function." - (isearch-search-fun-in-text-property - (funcall orig-fun) '(dired-filename dired-symlink-filename))) + (let ((search-fun + (isearch-search-fun-in-text-property + (funcall orig-fun) '(dired-filename dired-symlink-filename)))) + (lambda (&rest args) + (font-lock-ensure) + (apply search-fun args)))) ;;;###autoload (defun dired-isearch-filenames () =2D- 2.39.2 --=-=-= Content-Type: text/plain A related question is whether everybody always wants to search in symlink targets when isearching file names in dired... I don't. Would it be worth to add an option for that? Currently the properties are just hardcoded. Then, in the above patch we could make the `font-lock-ensure' call depend on the value of that option. > Also noticed that doing the first replacement always raises an error: > > Debugger entered--Lisp error: (error "Match data clobbered by buffer > modification hooks") > replace-match("!" nil nil) > replace-match-maybe-edit("!" nil nil nil (672 673 #) nil) > perform-replace("7" "!" t t nil nil nil nil nil nil nil) > query-replace-regexp("7" "!" nil nil nil nil nil) > funcall-interactively(query-replace-regexp "7" "!" nil nil nil nil nil) > command-execute(query-replace-regexp) Do I interpret the code in replace_match correctly: this error doesn't even mean the match data has been clobbered - only that modification hooks called searching functions? I don't know what the referenced search_regs.num_regs exactly contains. But we already seem to ensure not to clobber match data. Michael. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 09 13:19:22 2024 Received: (at 73018) by debbugs.gnu.org; 9 Sep 2024 17:19:22 +0000 Received: from localhost ([127.0.0.1]:33965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sni2s-0001Td-4F for submit@debbugs.gnu.org; Mon, 09 Sep 2024 13:19:22 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:47557) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sni2q-0001TN-Os for 73018@debbugs.gnu.org; Mon, 09 Sep 2024 13:19:21 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3E6B8C0003; Mon, 9 Sep 2024 17:18:48 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87bk0w511c.fsf@web.de> (Michael Heerdegen's message of "Mon, 09 Sep 2024 16:55:59 +0200") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> Date: Mon, 09 Sep 2024 20:13:18 +0300 Message-ID: <86h6ao7ntd.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) > Would something like this be good? > > @@ -3740,8 +3740,12 @@ dired-isearch-search-filenames > - (isearch-search-fun-in-text-property > - (funcall orig-fun) '(dired-filename dired-symlink-filename))) > + (let ((search-fun > + (isearch-search-fun-in-text-property > + (funcall orig-fun) '(dired-filename dired-symlink-filename)))) > + (lambda (&rest args) > + (font-lock-ensure) > + (apply search-fun args)))) This will call 'font-lock-ensure' for every search hit? Wouldn't it be better to call 'font-lock-ensure' only once at the beginning of the search? > A related question is whether everybody always wants to search in > symlink targets when isearching file names in dired... I don't. Would > it be worth to add an option for that? Currently the properties are > just hardcoded. > > Then, in the above patch we could make the `font-lock-ensure' call > depend on the value of that option. Maybe not an option, but just a simple variable? From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 09 13:19:25 2024 Received: (at 73018) by debbugs.gnu.org; 9 Sep 2024 17:19:25 +0000 Received: from localhost ([127.0.0.1]:33968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sni2v-0001Ts-EE for submit@debbugs.gnu.org; Mon, 09 Sep 2024 13:19:25 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:51853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sni2t-0001TR-DZ for 73018@debbugs.gnu.org; Mon, 09 Sep 2024 13:19:23 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3E7581BF205; Mon, 9 Sep 2024 17:18:51 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87bk0w511c.fsf@web.de> (Michael Heerdegen's message of "Mon, 09 Sep 2024 16:55:59 +0200") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> Date: Mon, 09 Sep 2024 20:14:15 +0300 Message-ID: <86a5gg7nrs.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) >> Also noticed that doing the first replacement always raises an error: >> >> Debugger entered--Lisp error: (error "Match data clobbered by buffer >> modification hooks") >> replace-match("!" nil nil) >> replace-match-maybe-edit("!" nil nil nil (672 673 #) nil) >> perform-replace("7" "!" t t nil nil nil nil nil nil nil) >> query-replace-regexp("7" "!" nil nil nil nil nil) >> funcall-interactively(query-replace-regexp "7" "!" nil nil nil nil nil) >> command-execute(query-replace-regexp) > > Do I interpret the code in replace_match correctly: this error doesn't > even mean the match data has been clobbered - only that modification > hooks called searching functions? I don't know what the referenced > search_regs.num_regs exactly contains. But we already seem to ensure > not to clobber match data. It fails in emacs-30, but not in emacs-29. So this is a regression. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 09 13:54:46 2024 Received: (at 73018) by debbugs.gnu.org; 9 Sep 2024 17:54:46 +0000 Received: from localhost ([127.0.0.1]:34036 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snib7-0003HA-UE for submit@debbugs.gnu.org; Mon, 09 Sep 2024 13:54:46 -0400 Received: from mout.web.de ([212.227.15.14]:54639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snib5-0003Gq-ND for 73018@debbugs.gnu.org; Mon, 09 Sep 2024 13:54:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1725904466; x=1726509266; i=michael_heerdegen@web.de; bh=wCXXjw+2uUDBx3/iS+zoOJAlu0OxuCXEp9hH3Cg8v88=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=d5f5+LQ7kyD4GW4gNu3WTqpZ5hMM6tmWlIEPojxdg/5TfOmgeqhiueNWO8MSTkJE I24bQpCaMbkjr404b7V3QGN4nwQ2Z013X+Rf4V7z9od9j9jXW8sn82oVSmJekoPtV 2ANq1pFZ+HnXhthVjyYsbyweHL30b6sXbJMImso2HRd0XEFiixAYj+8RVn7i8cq6r Yql7d4nDjEa6j63Ze8kj9vEzYPdwR3LSjOg51nZccwepPqsO6IZSsmpihe5T+hkM+ C0kzeq/otBPj6GD7Zy8BtdslZqsClJaYzQ1nSks7tLqx19gfFuiZB7EarqTN51DJd qdqqt1zuJIbVW2qz1Q== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.176]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M28WT-1slFkm460H-00F9TU; Mon, 09 Sep 2024 19:54:26 +0200 From: Michael Heerdegen To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86h6ao7ntd.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 09 Sep 2024 20:13:18 +0300") References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86h6ao7ntd.fsf@mail.linkov.net> Date: Mon, 09 Sep 2024 19:55:14 +0200 Message-ID: <878qw0empp.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:uJn6ZjiJIooxBOy3GJIIpwVwf4Ie5l9UE4RjYI3h408umsx4pWZ KUgx8zFp1KDW4RLMry9GIU6XqL+YCwW/GG4Iau8PmPPf2cmv3hiFAElnEf578ZYDZCFtWWR 7+dQLo7BhHhRM54nDbcRtlbl2ZdxP/LFvJAHP2C0b0QVEjMPwbC+7wjxcfCzQ59XsSjO9Mt N3o1SpUXwcqwPDBkkiHAw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:F9P5vgG3BrM=;8sq3eWeEIhwsP9YIlxQds9ZB44G anKpSmd/0mAX/si5dCCfrjzZnP9yx4lqqFRPrItVFMCpxwsgeb5aeWTJkTrVQwBwGyROJX2+u +23bCj7UkhIKSyKtKcznW8pm/AnJJrS6KLM0bMl41CwqF57J5nBR83w8b/mhYrzDQfndI91O7 nVney+wBJr5WfNJDWJ2qnuO0ywsdM1D/flVosf+fDUsF91lMgyvd/SLs8PjTzTgFkFK30ebbL yS4diheXBlAyi7arYhUwAUbQ5+9bHot6gjdSNm95OJowHNye+0HEnVBV0MYyEI65YhApn66EW L0hAIyr40DKzxa887JlyGztTceCq2qyCc8slI1HiXATQ5B6ZJigBr8ALfXhcdKk5BBaKjp04Z IWgJfl9DXy6RboKCVfoz6jFX/RllRFii8EcArzHtZeDIAhfhLK84+wktYhagJg2M1xAVPSZUp uzVCFsTcSsSjaKuHQySqpfEBfHS2r5efHvlqpNjLopf093hF3YB73Ex8hKe6BI2KnQdfik8U8 viof/PWinfrAK2NrbynjRokel3WLktTM47fATF/hMJQ/mxpL1zNArJN37hxMLDBPWcttmONb+ RNk496SvovTvoPfED2Wo3w7eOj1f7Bd9w1T/ZdUo2JkB3XnlYEdcw1gxp2uoxtdaY2e2TSBsA +lmuz8fNI0K4dHkGusyKKR3h1sFSFmGR8KpMEQodSCH8+AS8ZKHx2MRCjjRHGQ9ymDCTMI/27 JiHFnypsZisIT8aouTcwx4eVKUNpN0C7YaRMi/VbdIQSaRpx3k8vCb3eQypum9jf45UAgp6ae sMSVtjZJoCt9nlrafTBsPWYcReDln1MSgngQot6oCzoLg= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@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.7 (-) Juri Linkov writes: > > Would something like this be good? > > > > @@ -3740,8 +3740,12 @@ dired-isearch-search-filenames > > - (isearch-search-fun-in-text-property > > - (funcall orig-fun) '(dired-filename dired-symlink-filename))) > > + (let ((search-fun > > + (isearch-search-fun-in-text-property > > + (funcall orig-fun) '(dired-filename dired-symlink-filename)))) > > + (lambda (&rest args) > > + (font-lock-ensure) > > + (apply search-fun args)))) > > This will call 'font-lock-ensure' for every search hit? Right - this is the wrong place to add it. The idea was to make the search function itself know that it has to care about font-locking. We could still save the information in the function by using an oclosure, though. Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 10 02:43:25 2024 Received: (at 73018) by debbugs.gnu.org; 10 Sep 2024 06:43:25 +0000 Received: from localhost ([127.0.0.1]:34688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snuaz-0008RW-6A for submit@debbugs.gnu.org; Tue, 10 Sep 2024 02:43:25 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:58935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snuax-0008RB-4k for 73018@debbugs.gnu.org; Tue, 10 Sep 2024 02:43:24 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 299EB60002; Tue, 10 Sep 2024 06:42:48 +0000 (UTC) From: Juri Linkov To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86a5gg7nrs.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 09 Sep 2024 20:14:15 +0300") Organization: LINKOV.NET References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> Date: Tue, 10 Sep 2024 09:28:50 +0300 Message-ID: <86tteo3wmh.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: Madhu , 73018@debbugs.gnu.org, Stefan Monnier 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.7 (-) >>> Also noticed that doing the first replacement always raises an error: >>> >>> Debugger entered--Lisp error: (error "Match data clobbered by buffer >>> modification hooks") >>> replace-match("!" nil nil) >>> replace-match-maybe-edit("!" nil nil nil (672 673 #) nil) >>> perform-replace("7" "!" t t nil nil nil nil nil nil nil) >>> query-replace-regexp("7" "!" nil nil nil nil nil) >>> funcall-interactively(query-replace-regexp "7" "!" nil nil nil nil nil) >>> command-execute(query-replace-regexp) >> >> Do I interpret the code in replace_match correctly: this error doesn't >> even mean the match data has been clobbered - only that modification >> hooks called searching functions? I don't know what the referenced >> search_regs.num_regs exactly contains. But we already seem to ensure >> not to clobber match data. > > It fails in emacs-30, but not in emacs-29. > So this is a regression. This is caused by commit 63588775fcb, so Cc-ing Stefan. But probably this commit just exposed the problem that existed before? Anyway here is 100% reproducible recipe: 0. emacs -Q 1. 'C-x C-q' in a Dired with symlinks 2. 'C-M-% some_part_of_symlink RET anything RET' 3. 'y' => (error "Match data clobbered by buffer modification hooks") This happens only for the first replacement after `emacs -Q`. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 10 09:22:09 2024 Received: (at 73018) by debbugs.gnu.org; 10 Sep 2024 13:22:09 +0000 Received: from localhost ([127.0.0.1]:35061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1so0oq-00039U-V6 for submit@debbugs.gnu.org; Tue, 10 Sep 2024 09:22:09 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1so0op-000390-9b for 73018@debbugs.gnu.org; Tue, 10 Sep 2024 09:22:08 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6364144125A; Tue, 10 Sep 2024 09:21:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1725974513; bh=5pncrJe/pNqGJIJwmS5t0GAO1io/42LCsJkVzRHchB8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LXu93oK88SHbVLXGrHoyJITWVvBYg/oOffdfVwC16eHR9vjYi4AaRemOBYvjDeGss 0QLksSy6T440e+ttMfCvuyV+444UJ5aSSryYIE5U6d9WW9mQBffnads5Kb08PY0Mf/ VFMX4PwoEuKwJDtOv7obnI7WGyGObBVCB4CY+zJYA5wwFj8BsJ+O8Fjr2zhYTnF2Nl 7uPNKptT0k9qOSiTC+U2NUYOT2aFbUV47+LkfTyZ01cn/hlxkqVm3JMEOny+x1atOC YDuRKSiutXf+1bazQoyGzDgg9jWTmP10RTfrenFePvfetNQMWOF/K9fc9s8/RKJwA2 HPX+R9zEUOrJg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C13F04412A5; Tue, 10 Sep 2024 09:21:53 -0400 (EDT) Received: from pastel (104-195-217-100.cpe.teksavvy.com [104.195.217.100]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 92F83120183; Tue, 10 Sep 2024 09:21:53 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86tteo3wmh.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 10 Sep 2024 09:28:50 +0300") Message-ID: References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> Date: Tue, 10 Sep 2024 09:21:46 -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.003 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: 73018 Cc: Michael Heerdegen , Madhu , 73018@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.3 (---) > This is caused by commit 63588775fcb, so Cc-ing Stefan. > > But probably this commit just exposed the problem > that existed before? I think you're on to something. > => (error "Match data clobbered by buffer modification hooks") This comes from if (search_regs.num_regs != num_regs) error ("Match data clobbered by buffer modification hooks"); But this test is not doing what it is intended to do: it doesn't check whether the match data has changed. It just checks whether the size of the arrays we have allocated to hold the match data has changed. I got to that conclusion after narrowing down the origin of the error and finding out that the problem is that `search_regs.num_regs` is set to 13 before the first call to `wdired--restore-properties` but to 23 afterwards. We should probably use something like ptrdiff_t search_regs_last_reg (void) { ptrdiff_t i = search_regs.num_regs - 1; while (i >= 0 && search_regs.start[i] < 0) i--; return i; } instead of `search_regs.num_regs`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 10 09:27:45 2024 Received: (at 73018) by debbugs.gnu.org; 10 Sep 2024 13:27:45 +0000 Received: from localhost ([127.0.0.1]:35074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1so0uH-0003b7-H2 for submit@debbugs.gnu.org; Tue, 10 Sep 2024 09:27:45 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1so0uG-0003ap-3e for 73018@debbugs.gnu.org; Tue, 10 Sep 2024 09:27:44 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 653EA4412D7; Tue, 10 Sep 2024 09:27:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1725974851; bh=GtrvmINFnkJGuwV5Q8bGcN7qdAKDaFr1VASOy0dx/lI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RUiCoH4D65G3HA99da1BS6e1/SXmINkYxfT7qx/oBZKlrmGHP1UirT5Fnk3xi3AAQ p4OLcBckoNa1SdQe0tbA3yvsUH7wIdvCks6gZpkVMOrfxtqituKpPC//eRCcskU0xr lomftDR7obvnFNNlFav0oUYNPvK6PGptlMYO/ppVWsAjuV1d9FuNtZbca/fzxPWvxS j/WPpcBgw5gq4ddRUPaLkBszb9cdF12ZuEjJRcEv95WktqV8mc8QvdpHIxjcT1exip 3xYDMlvoCRKjCDN6fOeheFqakUsItg0hNpOll4VrcyLxgD8DY5jYfBsuNYAvs3MtmA yF33RhTR7IENA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D134A4412A5; Tue, 10 Sep 2024 09:27:31 -0400 (EDT) Received: from pastel (104-195-217-100.cpe.teksavvy.com [104.195.217.100]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A796D12020E; Tue, 10 Sep 2024 09:27:31 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: (Stefan Monnier's message of "Tue, 10 Sep 2024 09:21:46 -0400") Message-ID: References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> Date: Tue, 10 Sep 2024 09:27:31 -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.002 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: 73018 Cc: Michael Heerdegen , Madhu , 73018@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.3 (---) > We should probably use something like > > ptrdiff_t > search_regs_last_reg (void) > { > ptrdiff_t i = search_regs.num_regs - 1; > while (i >= 0 && search_regs.start[i] < 0) > i--; > return i; > } > > instead of `search_regs.num_regs`. And maybe we should consider changing `struct re_search` to keep track of the last non-nil subgroup. Currently, things like `match-data` loop through all the elements of `search_regs` whose size depends on the size (in number of subgroups) of the largest regexp we have ever matched so far, rather than the actual number of subgroups currently in use, so there's some wasted work there. Maybe the cost of maintaining the "last reg" would pay off. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 14 05:47:48 2024 Received: (at 73018) by debbugs.gnu.org; 14 Sep 2024 09:47:48 +0000 Received: from localhost ([127.0.0.1]:44846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spPNb-0001qI-Jb for submit@debbugs.gnu.org; Sat, 14 Sep 2024 05:47:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spPNZ-0001q2-5o for 73018@debbugs.gnu.org; Sat, 14 Sep 2024 05:47:46 -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 1spPNI-0000GA-BH; Sat, 14 Sep 2024 05:47: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=JEUXwCNa9YCnvoe1nHGVgjkgH7ioI3aPCSe1mOKur9w=; b=JIkeTgZii/Tc IRQmIYH2CQdzu2QJ2J5h0ZBIFa7XVuys9PWshQt/fGb8HqPUYmuclfZlAwHfUGtfb9T0BDZHxLEB1 9RdJQ/8SyNJVpybLKwe/Gq3mhmNQQ15wBaFioOUlUWRvpjBJD8JLsq36iUCAMq34Tvc75xPnU5WNz IzYVcrACZGTHHZV3/pbb4mp2m00BMG0b8OGRpBLRJ5sdyJgI/l1ZUib7OpkRTJcHYfKoIbqZGtEAM iZ6ZBi8sAlPAzoAV4V32Yaqwo5rjKEXuZDG99XTjXEAYdi2tw4r/YiajAsre6Pd2t/XXpWfj5pvIz OcNu1SbHWICWQSi3OlTd2w==; Date: Sat, 14 Sep 2024 12:47:26 +0300 Message-Id: <86h6aih8i9.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73018 Cc: michael_heerdegen@web.de, enometh@meer.net, 73018@debbugs.gnu.org, 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 (---) > Cc: Michael Heerdegen , Madhu , > 73018@debbugs.gnu.org > Date: Tue, 10 Sep 2024 09:27:31 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > We should probably use something like > > > > ptrdiff_t > > search_regs_last_reg (void) > > { > > ptrdiff_t i = search_regs.num_regs - 1; > > while (i >= 0 && search_regs.start[i] < 0) > > i--; > > return i; > > } > > > > instead of `search_regs.num_regs`. > > And maybe we should consider changing `struct re_search` to keep track > of the last non-nil subgroup. Currently, things like `match-data` loop > through all the elements of `search_regs` whose size depends on the > size (in number of subgroups) of the largest regexp we have ever matched > so far, rather than the actual number of subgroups currently in use, so > there's some wasted work there. Maybe the cost of maintaining the "last > reg" would pay off. Since this is a regression in Emacs 30, I'd like to solve it on the release branch. Can you suggest the safest fix you can come up with for that purpose? TIA From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 15 09:05:12 2024 Received: (at 73018) by debbugs.gnu.org; 15 Sep 2024 13:05:12 +0000 Received: from localhost ([127.0.0.1]:48615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spowC-00038F-9n for submit@debbugs.gnu.org; Sun, 15 Sep 2024 09:05:12 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8145) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spowA-000380-Gb for 73018@debbugs.gnu.org; Sun, 15 Sep 2024 09:05:10 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 480E280A75; Sun, 15 Sep 2024 09:04:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1726405489; bh=PNSKFkvwueKf9uFE1UayFxj9hz7XqXQpeL0KNKPJK5o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=iChhO8aUnICQhdgSFQy8NJ/l9uMpdQnagxz7rbDJe7ndo+xkdYYQWMGeEZjB5HKay e+4Lw5e3P7Y3Vjf7gsQHZRt/wNf5chfGIZ41ubfsKy1BXZObaAbe8/ah0X1wCEYDGw i9adJwoWsfCGhCXW9PgToARy6b2pGnGQkI9mXIu+XWON9+06fBgoHGK1W+tMOFe7J+ VzzPuGtC4TPvbkynZMaGBl6BkRsmHRpSEnGy+pY+OYJfUqz5b4XueKxkzv7soIrryM 2lu/mPMDJ7iAda7rv4Gi65x8A8ydelxQR43bt69mgvYuDNm8Sw0dRSmvfqCkbOT6Or iXKSbuJo3AnZg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E23D68009D; Sun, 15 Sep 2024 09:04:49 -0400 (EDT) Received: from pastel (104-195-209-174.cpe.teksavvy.com [104.195.209.174]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A7CA2120470; Sun, 15 Sep 2024 09:04:49 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86h6aih8i9.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Sep 2024 12:47:26 +0300") Message-ID: References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> Date: Sun, 15 Sep 2024 09:04:40 -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.002 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: 73018 Cc: michael_heerdegen@web.de, enometh@meer.net, 73018@debbugs.gnu.org, 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 (---) >> > We should probably use something like >> > >> > ptrdiff_t >> > search_regs_last_reg (void) >> > { >> > ptrdiff_t i = search_regs.num_regs - 1; >> > while (i >= 0 && search_regs.start[i] < 0) >> > i--; >> > return i; >> > } >> > >> > instead of `search_regs.num_regs`. >> >> And maybe we should consider changing `struct re_search` to keep track >> of the last non-nil subgroup. Currently, things like `match-data` loop >> through all the elements of `search_regs` whose size depends on the >> size (in number of subgroups) of the largest regexp we have ever matched >> so far, rather than the actual number of subgroups currently in use, so >> there's some wasted work there. Maybe the cost of maintaining the "last >> reg" would pay off. > > Since this is a regression in Emacs 30, I'd like to solve it on the > release branch. Can you suggest the safest fix you can come up with > for that purpose? Oh, yes: just remove the check. Since `search_regs.num_regs` keeps track only of the size of the array (rather than the part of it currently in use), and the array is never shrunk, it changes *very* few times in an Emacs session, so this check we have triggers *extremely* rarely. The "correct" change I suggest above would definitely not be good for the release branch since it will likely catch more cases (and thus introduce regressions where code used to "work" but now signals an error). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 15 11:05:00 2024 Received: (at 73018) by debbugs.gnu.org; 15 Sep 2024 15:05:00 +0000 Received: from localhost ([127.0.0.1]:50429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spqo7-0001jm-TC for submit@debbugs.gnu.org; Sun, 15 Sep 2024 11:05:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spqo6-0001jW-4x for 73018@debbugs.gnu.org; Sun, 15 Sep 2024 11:04:59 -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 1spqlf-0004EL-L9; Sun, 15 Sep 2024 11:02: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=kYbSbBtHD85NPcHxnDFCC4e7+pTCMZTgCjS1eKomju0=; b=H24UdqhmCPtF R9aS68y7A4YOyED8WspSIMC0S+jp0ZacNeqk70HIPCOGtqK1XQtzQnXLeEuaLt89Dkf8McJv3umgF qoGD/gN/r23DaoVAeLJJGO6e25rAuNs42qllFzLFhBAuBe5ptlzimxH8fsRD3siaM4EtzhwZGKyMK YyMa1D5UbKDZO9EGo92PoYG4hw61IYOquLQ6wwsfbJM9B+JmARYC2DfH7ZkaRMxMFPPGcy0sG3IKX 7W0tjsiOBHPz1JI5qHGEQpGQyNq7NJYillaxDsQxFqza2PoW2JBWHjlAEZsmIbj/AfcHnx6mdmTfg gTYh0OsP8LyyYMoe6D4iow==; Date: Sun, 15 Sep 2024 18:02:22 +0300 Message-Id: <86zfo9c64h.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sun, 15 Sep 2024 09:04:40 -0400) Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73018 Cc: michael_heerdegen@web.de, enometh@meer.net, Ihor Radchenko , 73018@debbugs.gnu.org, 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: Stefan Monnier > Cc: juri@linkov.net, michael_heerdegen@web.de, enometh@meer.net, > 73018@debbugs.gnu.org > Date: Sun, 15 Sep 2024 09:04:40 -0400 > > > Since this is a regression in Emacs 30, I'd like to solve it on the > > release branch. Can you suggest the safest fix you can come up with > > for that purpose? > > Oh, yes: just remove the check. Whoa! We had that check there for 9 years, and it was introduced to avoid crashes (see bug#23869), so removing it now, during a pretest, is scary. Frankly, I'd rather revert the offending change which caused the regression and let Emacs 30 live with bug#65451, which it was supposed to fix. And I don't think I understand how a single line you moved in 63588775fcb could cause this check to signal an error in the scenario of this bug. Can you explain? From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 15 22:06:29 2024 Received: (at 73018) by debbugs.gnu.org; 16 Sep 2024 02:06:29 +0000 Received: from localhost ([127.0.0.1]:50752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sq18H-0004dt-HQ for submit@debbugs.gnu.org; Sun, 15 Sep 2024 22:06:29 -0400 Received: from smtp7.ctinetworks.com ([205.166.61.237]:59932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sq18G-0004di-7o for 73018@debbugs.gnu.org; Sun, 15 Sep 2024 22:06:28 -0400 X-ctinetworks-Watermark: 1727316370.68126@Y2UHPWnvcf60zdZ//yb/kw X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 5D517B18C.A61FD Received: from localhost (unknown [117.254.37.239]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp7.ctinetworks.com (Postfix) with ESMTPSA id 5D517B18C; Sun, 15 Sep 2024 22:06:06 -0400 (EDT) Date: Mon, 16 Sep 2024 07:36:11 +0530 (IST) Message-Id: <20240916.073611.65330355381543629.enometh@meer.net> To: eliz@gnu.org Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer From: Madhu In-Reply-To: <86zfo9c64h.fsf@gnu.org> References: <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Sep_16_07_36_11_2024_619)--" Content-Transfer-Encoding: 7bit X-Spam-Score: 3.5 (+++) 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: fwiw in a build on master with the earlier patch i posted (which turns on font-lock-mode, admittedly overkill), and the autoload cookie patch (attached) and a fresh compile I do not seem to trigger th [...] Content analysis details: (3.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [117.254.37.239 listed in zen.spamhaus.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 73018 Cc: michael_heerdegen@web.de, 73018@debbugs.gnu.org, yantar92@posteo.net, monnier@iro.umontreal.ca, 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: 2.5 (++) 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: fwiw in a build on master with the earlier patch i posted (which turns on font-lock-mode, admittedly overkill), and the autoload cookie patch (attached) and a fresh compile I do not seem to trigger th [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [117.254.37.239 listed in zen.spamhaus.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager ----Next_Part(Mon_Sep_16_07_36_11_2024_619)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit fwiw in a build on master with the earlier patch i posted (which turns on font-lock-mode, admittedly overkill), and the autoload cookie patch (attached) and a fresh compile I do not seem to trigger the replace-match error (with the wdired recipe) ----Next_Part(Mon_Sep_16_07_36_11_2024_619)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-lisp-wdired.el-wdired-before-change-fn-autoload-cook.patch" >From 41e4505815f58ee69255801a55dc07394f729930 Mon Sep 17 00:00:00 2001 From: Madhu Date: Wed, 4 Sep 2024 15:05:26 +0530 Subject: [PATCH] lisp/wdired.el: (wdired--before-change-fn): autoload cookie prevents a "match data clobbered" error --- lisp/wdired.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/wdired.el b/lisp/wdired.el index dd8b8640a89..6f1f7b06e35 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -306,6 +306,7 @@ wdired--self-insert (put 'wdired--self-insert 'delete-selection 'delete-selection-uses-region-p) +;;;###autoload (defun wdired--before-change-fn (beg end) (save-match-data (save-excursion -- 2.46.0.27.gfa3b914457 ----Next_Part(Mon_Sep_16_07_36_11_2024_619)---- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 16 10:24:19 2024 Received: (at 73018) by debbugs.gnu.org; 16 Sep 2024 14:24:19 +0000 Received: from localhost ([127.0.0.1]:53011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqCeI-00035c-Mx for submit@debbugs.gnu.org; Mon, 16 Sep 2024 10:24:18 -0400 Received: from mout.web.de ([217.72.192.78]:35473) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqCeH-00035C-1G for 73018@debbugs.gnu.org; Mon, 16 Sep 2024 10:24:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1726496621; x=1727101421; i=michael_heerdegen@web.de; bh=3WP1lYwVOeRARSjlEEogcv4BhxmC6PVOBot/HpplCeY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=MiuUNStX41q7Bv8t6erqz3SNino22FoGTHSSWGghKsX4AjusDJrpowUx1MydZH62 XhQoc0gKu4Oe6W2mqnUUQ/j9xjvnce4BMLnq1UA2obreViK5nKckBoYgTZ0JGhsAW 5Y68plO7XIUQVADJlXrybwu/JQCMILRWKc6LQuBdmw4MUpZvTHf1KPG11lx9krrNu lhFvlvEjTYveFLi6Bau0mHE/kkZ8aGorRgiS3HHvRvsKy3BHH1SoIXm/VDeZ3cCdq 90uuExs9yIS3bUc2V4pQfJ9WL2mH3OdPWf9htYtn6GKnYk3jvsA8W6f6h1rVXRY1A gkuZNGiLhoABzrdUXg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([88.66.201.158]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MIyeG-1sX0nH369S-00Z7fS; Mon, 16 Sep 2024 16:23:41 +0200 From: Michael Heerdegen To: Madhu Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <20240916.073611.65330355381543629.enometh@meer.net> (Madhu's message of "Mon, 16 Sep 2024 07:36:11 +0530 (IST)") References: <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> <20240916.073611.65330355381543629.enometh@meer.net> Date: Mon, 16 Sep 2024 16:24:34 +0200 Message-ID: <87ed5jznfh.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:FkP1Dwbbk7mc70pPTxhtOSX9lIdQs9QnfNBpkmhHPANqnrZQmdz zwoEHESyqBS5JEpI1buj5H5kYqmEMhr66ukL5guV0Z1zmxo55X2ec6Ifx10bdwHv+5Inia+ +u4j2LTN7lXk648NoqCu/lSXyt37eW30AuRI+r7LS6RTDv/S1/hB/hWn2CE74gQeXtWszBT emmAkqTCq5W8U1v2Ok55Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:L3CiNaDQAxo=;JX/MAoV5jeA8MJB+83CKmSfVcla NE+Y5nR0EfQ+8O97oaOFnXydgld6u22RhvEAbJMwHTt/MNyIiSHwBjkv0eOhyIyJXmcwocObT fNn5SYh7PedRTCJ+wj/hLHdLmvzSN/TdrqXJyZGl6QkX8RtaTotCvbSLqJhhO49eUZkQlLucy U3Y/i3PCUz2MOqyPgNXFDwNPduhid8Oxwd+/YWccy76ykhMWItSQuJUw+3iOauJoGQfCrNiAc h5cI1uccprERX8C5U5WeoElb0qWTOwxPWcJDQhJnXoo7ebx3/5Z/FanNHllIrp3Blh/O1N2TE rhCW3hMMmYtKIK74ON6RMzrn0t7lIVVsmp/l11SXaJmq7onssSBqPpLswF+wFsow5dsYKp348 Fc5M/Va6qz7u9VZG2uQDyr3s/aLACceeInSGf/liJSsnc8snub7El7k0EcjGESkRHjW3Yjc8t RYl5Kx1vu3zNUHcUsASFsq3KevLALvSiN9c/T2N6sG+YhGYNLLE3bB7Cq7BT6+/O1KL5HXRTN aB3d60K5xec8sVa5Cf2uEyKU9rPtx/GcXh1WensNJwYHYxlCROpNqV8fLaJXDCBf0tG2RYevP FTGmPdyJvHS/r6KTw93crGLCqzsvBZYP5xIumwMQF1IZAM7Ax9TvlOmG/vMYN8LjzSazE6D8t Ufj2+fh9HMKlLsTAGgzD8WdU4HSk3Gfv/ev49L4g8YaKyRDirCzZBrS5o5QlqVQi1oRohX9RT ifxaw4aEMrk9NZk36OXpOp3Mja9c1ds7OYDfdA1kO6kRCVkAKn8uB5p27gmPQi9U0o4brpsjR CJ0s7eJIpWaYib0vonNswa3g== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 73018 Cc: eliz@gnu.org, 73018@debbugs.gnu.org, yantar92@posteo.net, monnier@iro.umontreal.ca, 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: -1.7 (-) Madhu writes: > fwiw in a build on master with the earlier patch i posted (which turns > on font-lock-mode, admittedly overkill), and the autoload cookie patch > (attached) and a fresh compile I do not seem to trigger the > replace-match error (with the wdired recipe) Do you have an explanation for why this should make a difference? Because: all references to `wdired--before-change-fn' are in "wdired" itself, and whenever the function is called, "wdired" is necessarily already loaded. Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 14:53:28 2024 Received: (at 73018) by debbugs.gnu.org; 17 Sep 2024 18:53:28 +0000 Received: from localhost ([127.0.0.1]:55953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdKJ-0006Gl-GP for submit@debbugs.gnu.org; Tue, 17 Sep 2024 14:53:28 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdKH-0006GW-7b for 73018@debbugs.gnu.org; Tue, 17 Sep 2024 14:53:25 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 435594412FA; Tue, 17 Sep 2024 14:53:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1726599177; bh=LN82O9i7UJGJvZ+pZ1HxL/sxebqYvpYAtKj+8LY5Z+8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Oez37LanhguvjvJCnhR6YaSuZ9GJU0WhOKLkPZQXXKN7mArfyk3qObvCbNtSHSo33 Lr1/neoji8TnszFv2hBGXhJzSphXWPkPQyAjHDL24HVzLtqWS1gLdSlovybOIh9Khs VJ5PpnQZn9XShfEeZs7gBKcko32EJHFIf6jQs4tV3w+04VOWsXSAybINIXCxamncfn +uZ+Blh65dKuO/bY3WoyWP7GW7gc1LN5hPXSNiEyWe94kMOSBjSIZolXdAT3ktoX/d rF9Uf4rx9ekAXzPm7YWqw3PS3xxM1yLoKKud3WvRNrWRsHZTj+s3u5XyUFlaZWRc9w b8dZij9N0/hDw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BC5434412F0; Tue, 17 Sep 2024 14:52:57 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A2B801204E2; Tue, 17 Sep 2024 14:52:57 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86zfo9c64h.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 15 Sep 2024 18:02:22 +0300") Message-ID: References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> Date: Tue, 17 Sep 2024 14:52:57 -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.167 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: 73018 Cc: michael_heerdegen@web.de, enometh@meer.net, 73018@debbugs.gnu.org, Ihor Radchenko , 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 (---) >> > Since this is a regression in Emacs 30, I'd like to solve it on the >> > release branch. Can you suggest the safest fix you can come up with >> > for that purpose? >> >> Oh, yes: just remove the check. > > Whoa! We had that check there for 9 years, and it was introduced to > avoid crashes (see bug#23869), so removing it now, during a pretest, > is scary. Here's the story I see: In response to that bug, you proposed to add: /* Last line of defense, in case search registers were actually not saved (because someone else already occupied the save slots). */ if (search_regs.start[sub] != sub_start || search_regs.end[sub] != sub_end) error ("Match data clobbered by buffer modification hooks"); In the end, you added: commit 3a9d6296b35e5317c497674d5725eb52699bd3b8 Author: Eli Zaretskii Date: Mon Jul 4 18:34:40 2016 +0300 Avoid crashes when buffer modification hooks clobber match data * src/search.c (Freplace_match): Error out if buffer modification hooks triggered by buffer changes in replace_range, upcase-region, and upcase-initials-region clobber the match data needed to be adjusted for the replacement. (Bug#23869) diff --git a/src/search.c b/src/search.c --- a/src/search.c +++ b/src/search.c @@ -2699,0 +2707,5 @@ + if (search_regs.start[sub] != sub_start + || search_regs.end[sub] != sub_end + || search_regs.num_regs != num_regs) + error ("Match data clobbered by buffer modification hooks"); A bit later we dropped the start/end part (for a reason I'm not sure is valid, since change hooks that modify the buffer should be disallowed, I think): commit 487498e497f8c6b6303bd5feeac83a5bcc2315af Author: Noam Postavsky Date: Sun May 16 15:19:57 2021 +0200 Remove unreliable test for match data clobbering * src/search.c (Freplace_match): Don't test for change in search_regs start and end, this is unreliable if change hooks modify text earlier in the buffer (bug#35264). diff --git a/src/search.c b/src/search.c --- a/src/search.c +++ b/src/search.c @@ -2739,10 +2738,10 @@ /* The replace_range etc. functions can trigger modification hooks (see signal_before_change and signal_after_change). Try to error out if these hooks clobber the match data since clobbering can - result in confusing bugs. Although this sanity check does not - catch all possible clobberings, it should catch many of them. */ - if (! (search_regs.num_regs == num_regs - && search_regs.start[sub] == newstart - && search_regs.end[sub] == newpoint)) + result in confusing bugs. We used to check for changes in + search_regs start and end, but that fails if modification hooks + remove or add text earlier in the buffer, so just check num_regs + now. */ + if (search_regs.num_regs != num_regs) error ("Match data clobbered by buffer modification hooks"); So the check that remains is one that wasn't even present originally. Also, IIUC the origin of the crash in bug#23869 is that we did: /* Adjust search data for this change. */ { ptrdiff_t oldend = search_regs.end[sub]; after running the change functions (i.e. at a time where `search_regs.end[sub]` might not hold the same match data and hence might be -1, leading to the crash). This code is different now. The only place where we use something like `search_regs.end[sub]` once it's possibly-clobbered is: if (case_action == all_caps) Fupcase_region (make_fixnum (search_regs.start[sub]), make_fixnum (newpoint), Qnil); else if (case_action == cap_initial) Fupcase_initials_region (make_fixnum (search_regs.start[sub]), make_fixnum (newpoint), Qnil); both of whose functions should not crash just because they're called with a -1. So I think the original crash should not happen nowadays, and this is because the "Adjust search data" part of the code was completely rewritten by: commit 66f95e0dabf750e9d2eff59b2bb6e593618cd48a Author: Noam Postavsky Date: Wed Jul 20 20:15:14 2016 -0400 Adjust match data before calling after-change-funs It's important to adjust the match data in between calling before-change-functions and after-change-functions, so that buffer change hooks will always see match-data consistent with buffer content. (Bug #23917) * src/insdel.c (replace_range): Add new parameter ADJUST_MATCH_DATA, if true call update_search_regs. Update all callers (except Freplace_match) to pass 0 for the new parameter. * src/search.c (update_search_regs): New function, extracted from Freplace_match. (Freplace_match): Remove match data adjustment code, pass 1 for ADJUST_MATCH_DATA to replace_range instead. > And I don't think I understand how a single line you moved in > 63588775fcb could cause this check to signal an error in the scenario > of this bug. Can you explain? The line-move caused the modification hooks to be run at a different moment: we used to run them *after* the if+error check whereas now we run them before. The problem can probably be triggered in the old code as well if `case_action` is given a different value (in which case the `Fupcase_region` may also run the hooks, thus potentially causing the same change to the size of the `search_regs.start/end` arrays before the if+error check). Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 17 14:57:54 2024 Received: (at 73018) by debbugs.gnu.org; 17 Sep 2024 18:57:54 +0000 Received: from localhost ([127.0.0.1]:55958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdOc-0006Wg-Ip for submit@debbugs.gnu.org; Tue, 17 Sep 2024 14:57:54 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqdOb-0006WP-5u for 73018@debbugs.gnu.org; Tue, 17 Sep 2024 14:57:53 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id A294410017F; Tue, 17 Sep 2024 14:57:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1726599450; bh=VxiKeKYMVaj51zlnv2ocOTLYLsBIw84WINvO9WZz8FE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nyx5S0EHCdk1styLYV6kg+GA1rjvPWoYi4Giq3uudNPBQXTDkB/6o3RWz1O+yHoSo s0XwfiMWsyswUPsflVpBF79xVvJRQUfLAjsAK/0CGocbl3EoKMFBgu75t9K7XI6g/v M/AQXGOgbuaEf2Z6gJvXl+iivGQ0vNhG03Wjm1glbpfhpUSTZl9xyXURyzLRPlkryU ZbxoezLsyHRC1PEGE4JkuJNMK6BbEC622EoNtAwjtOTBozHh06otqeaTu77qiQphza oDYo1uLceXMVirlwEIMQYGbY8Nkqm58BkSQFU7lzCL/WVFm0L5i0PDA7BXi8Y0gvu4 /MNWV3K/6w31Q== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 68BF4100043; Tue, 17 Sep 2024 14:57:30 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4A4911200EC; Tue, 17 Sep 2024 14:57:30 -0400 (EDT) From: Stefan Monnier To: Michael Heerdegen Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <87ed5jznfh.fsf@web.de> (Michael Heerdegen's message of "Mon, 16 Sep 2024 16:24:34 +0200") Message-ID: References: <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> <20240916.073611.65330355381543629.enometh@meer.net> <87ed5jznfh.fsf@web.de> Date: Tue, 17 Sep 2024 14:57:29 -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.149 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: 73018 Cc: Madhu , 73018@debbugs.gnu.org, yantar92@posteo.net, eliz@gnu.org, 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 (---) > Do you have an explanation for why this should make a difference? The bug shows up if the `search_regs.start/end` happen to be resized (grown) during the modification hooks (and only if that happens when running those hooks inside `replace_match`). Those arrays are resized only when we use a regexp that has more groups than the "largest" regexp we've encountered so far. So the problem disappears as soon as we use the "largest" regexp time before we use it from within a change hook run from within `replace_match`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 21 05:34:48 2024 Received: (at 73018-done) by debbugs.gnu.org; 21 Sep 2024 09:34:48 +0000 Received: from localhost ([127.0.0.1]:37182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srwVr-000328-NY for submit@debbugs.gnu.org; Sat, 21 Sep 2024 05:34:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srwVp-00031u-7O for 73018-done@debbugs.gnu.org; Sat, 21 Sep 2024 05:34:46 -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 1srwVM-00088W-6v; Sat, 21 Sep 2024 05:34:16 -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=7c6a3GdoBFKMnmDCujndQl/JzAb+OIAQUdogVlPUJ0U=; b=jaYH2KahaTDr /IDVEbzl3NKoO9LPbZvtdO2m/50GO2Wqqj59C8fW6L92FyF0o//B2OddnpDEhWyqp5tvEAwUzJ9YR N6O9VycL8wWcP/wNl58oZTBMyiKCc4k/0pkSxa3brGdlTaj2VpwgyxLErzPopmPWKWHFpRsh36TkS HQsb7qjPQ/McUB4N7Pl21Kxqc0ouZs6TrtLkOJkhlHzXHtszfNJK486tSMYZg1QWR7Mw5kCRfBOzG MLHF5YMbYg6AGMJh0Zt7ROBxPJPq8DpMG84SQZoLkQWRAixpNz4v25ieK6TAKqRVNGU/Ug5Jg4Er3 /YCZHLd+vf3VVluAI5gYKQ==; Date: Sat, 21 Sep 2024 12:34:12 +0300 Message-Id: <86ldzl4agb.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Tue, 17 Sep 2024 14:52:57 -0400) Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73018-done Cc: michael_heerdegen@web.de, enometh@meer.net, 73018-done@debbugs.gnu.org, yantar92@posteo.net, 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: Stefan Monnier > Cc: michael_heerdegen@web.de, enometh@meer.net, Ihor Radchenko > , 73018@debbugs.gnu.org, juri@linkov.net > Date: Tue, 17 Sep 2024 14:52:57 -0400 > > >> > Since this is a regression in Emacs 30, I'd like to solve it on the > >> > release branch. Can you suggest the safest fix you can come up with > >> > for that purpose? > >> > >> Oh, yes: just remove the check. > > > > Whoa! We had that check there for 9 years, and it was introduced to > > avoid crashes (see bug#23869), so removing it now, during a pretest, > > is scary. > > Here's the story I see: > In response to that bug, you proposed to add: > > /* Last line of defense, in case search registers were actually not > saved (because someone else already occupied the save slots). */ > if (search_regs.start[sub] != sub_start > || search_regs.end[sub] != sub_end) > error ("Match data clobbered by buffer modification hooks"); > > In the end, you added: > > commit 3a9d6296b35e5317c497674d5725eb52699bd3b8 > Author: Eli Zaretskii > Date: Mon Jul 4 18:34:40 2016 +0300 > > Avoid crashes when buffer modification hooks clobber match data > > * src/search.c (Freplace_match): Error out if buffer modification > hooks triggered by buffer changes in replace_range, upcase-region, > and upcase-initials-region clobber the match data needed to be > adjusted for the replacement. (Bug#23869) > > diff --git a/src/search.c b/src/search.c > --- a/src/search.c > +++ b/src/search.c > @@ -2699,0 +2707,5 @@ > + if (search_regs.start[sub] != sub_start > + || search_regs.end[sub] != sub_end > + || search_regs.num_regs != num_regs) > + error ("Match data clobbered by buffer modification hooks"); > > A bit later we dropped the start/end part (for a reason I'm not sure is > valid, since change hooks that modify the buffer should be disallowed, > I think): > > commit 487498e497f8c6b6303bd5feeac83a5bcc2315af > Author: Noam Postavsky > Date: Sun May 16 15:19:57 2021 +0200 > > Remove unreliable test for match data clobbering > > * src/search.c (Freplace_match): Don't test for change in search_regs > start and end, this is unreliable if change hooks modify text earlier > in the buffer (bug#35264). > > diff --git a/src/search.c b/src/search.c > --- a/src/search.c > +++ b/src/search.c > @@ -2739,10 +2738,10 @@ > /* The replace_range etc. functions can trigger modification hooks > (see signal_before_change and signal_after_change). Try to error > out if these hooks clobber the match data since clobbering can > - result in confusing bugs. Although this sanity check does not > - catch all possible clobberings, it should catch many of them. */ > - if (! (search_regs.num_regs == num_regs > - && search_regs.start[sub] == newstart > - && search_regs.end[sub] == newpoint)) > + result in confusing bugs. We used to check for changes in > + search_regs start and end, but that fails if modification hooks > + remove or add text earlier in the buffer, so just check num_regs > + now. */ > + if (search_regs.num_regs != num_regs) > error ("Match data clobbered by buffer modification hooks"); > > So the check that remains is one that wasn't even present originally. > > Also, IIUC the origin of the crash in bug#23869 is that we did: > > /* Adjust search data for this change. */ > { > ptrdiff_t oldend = search_regs.end[sub]; > > after running the change functions (i.e. at a time where > `search_regs.end[sub]` might not hold the same match data and hence > might be -1, leading to the crash). > > This code is different now. The only place where we use something like > `search_regs.end[sub]` once it's possibly-clobbered is: > > if (case_action == all_caps) > Fupcase_region (make_fixnum (search_regs.start[sub]), > make_fixnum (newpoint), > Qnil); > else if (case_action == cap_initial) > Fupcase_initials_region (make_fixnum (search_regs.start[sub]), > make_fixnum (newpoint), Qnil); > > both of whose functions should not crash just because they're called > with a -1. So I think the original crash should not happen nowadays, > and this is because the "Adjust search data" part of the code was > completely rewritten by: > > commit 66f95e0dabf750e9d2eff59b2bb6e593618cd48a > Author: Noam Postavsky > Date: Wed Jul 20 20:15:14 2016 -0400 > > Adjust match data before calling after-change-funs > > It's important to adjust the match data in between calling > before-change-functions and after-change-functions, so that buffer > change hooks will always see match-data consistent with buffer content. > (Bug #23917) > > * src/insdel.c (replace_range): Add new parameter ADJUST_MATCH_DATA, if > true call update_search_regs. Update all callers (except > Freplace_match) to pass 0 for the new parameter. > * src/search.c (update_search_regs): New function, extracted from > Freplace_match. > (Freplace_match): Remove match data adjustment code, pass 1 for > ADJUST_MATCH_DATA to replace_range instead. > > > And I don't think I understand how a single line you moved in > > 63588775fcb could cause this check to signal an error in the scenario > > of this bug. Can you explain? > > The line-move caused the modification hooks to be run at a different > moment: we used to run them *after* the if+error check whereas now we > run them before. The problem can probably be triggered in the old code > as well if `case_action` is given a different value (in which case the > `Fupcase_region` may also run the hooks, thus potentially causing the > same change to the size of the `search_regs.start/end` arrays before the > if+error check). Thanks for the analysis. Call me a coward, but I don't want to make this change on the release branch. Instead, I reverted the search.c part of the 63588775fcb commit there (which will re-introduce bug#65451, sigh). I did install the change you suggested on master. And with that, I'm closing this bug. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 22 23:43:38 2024 Received: (at 73018-done) by debbugs.gnu.org; 23 Sep 2024 03:43:38 +0000 Received: from localhost ([127.0.0.1]:43022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssZz8-0007J3-4y for submit@debbugs.gnu.org; Sun, 22 Sep 2024 23:43:38 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:55945) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssZz5-0007Io-Oh for 73018-done@debbugs.gnu.org; Sun, 22 Sep 2024 23:43:36 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6142E100044; Sun, 22 Sep 2024 23:43:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1727062985; bh=3CraCw62PGuKWb5keJewlDXiBXQlTBdOky5YVAyYUpc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VRXpz+jgxWo17TX2vCdNjwr5sraIcHBcrAlfqmRA9ebxs+LgvU8zfRzWMwu5+GVpt HkrYNb8ak424tqfPC4m3CJ1r15HRPNTkTBbVL7ygKhAjuc5e1xQFLV7Cjo+0jDpasr Osw0GF3J4NASQbsG31Hz0UPQepfMF9TUgS7MRtD82KYzW2ZZX4GtqKMTk8INAH5uEi baIMTDz68SIbrBiN3UUQfDtYeqhhX0utKvA5L96COBqdS1vlFkeDkvKkvij/1xWjEf EZXbci/IeZnFkiOq28tSGqeKPFzLuNbWuT87vZnYDnP/LD0xtJZNL///egfGksiIkT XLOz2ApUP+cnA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4FD57100035; Sun, 22 Sep 2024 23:43:05 -0400 (EDT) Received: from pastel (unknown [45.72.221.103]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1052F12068E; Sun, 22 Sep 2024 23:43:05 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer In-Reply-To: <86ldzl4agb.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Sep 2024 12:34:12 +0300") Message-ID: References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> <86ldzl4agb.fsf@gnu.org> Date: Sun, 22 Sep 2024 23:43:03 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: 73018-done Cc: michael_heerdegen@web.de, enometh@meer.net, 73018-done@debbugs.gnu.org, yantar92@posteo.net, 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 (---) --=-=-= Content-Type: text/plain > bug#65451, sigh). I did install the change you suggested on master. > And with that, I'm closing this bug. BTW, for `master` I think a better change is to fix the check. E.g. with the patch below. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=search.patch diff --git a/src/search.c b/src/search.c index 24b1ee6bd3f..718d23b919e 100644 --- a/src/search.c +++ b/src/search.c @@ -2356,6 +2356,18 @@ DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1, { return search_command (regexp, bound, noerror, count, 1, true, true); } + +/* Return the number of search regs currently used. + FIXME: Maybe we should keep this as a field in `search_regs` rather + than (re)computing it dynamically. */ +static ptrdiff_t +search_regs_num_used (void) +{ + ptrdiff_t last = search_regs.num_regs - 1; + while (last >= 0 && search_regs.start[last] < 0) + last--; + return last + 1; +} DEFUN ("replace-match", Freplace_match, Sreplace_match, 1, 5, 0, doc: /* Replace text matched by last search with NEWTEXT. @@ -2759,11 +2771,22 @@ DEFUN ("replace-match", Freplace_match, Sreplace_match, 1, 5, 0, } newpoint = sub_start + SCHARS (newtext); + ptrdiff_t num_used = search_regs_num_used (); /* Replace the old text with the new in the cleanest possible way. */ replace_range (sub_start, sub_end, newtext, 1, 0, 1, true, true); signal_after_change (sub_start, sub_end - sub_start, SCHARS (newtext)); + if (search_regs_num_used () != num_used) + /* The replace_range etc. functions can trigger modification hooks + (see signal_before_change and signal_after_change). Try to error + out if these hooks clobber the match data since clobbering can + result in confusing bugs. We used to check for changes in + search_regs start and end, but that fails if modification hooks + remove or add text earlier in the buffer, so just check num_regs + now. */ + error ("Match data clobbered by buffer modification hooks"); + if (case_action == all_caps) Fupcase_region (make_fixnum (search_regs.start[sub]), make_fixnum (newpoint), @@ -2869,7 +2892,8 @@ DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0, { Lisp_Object tail, prev; Lisp_Object *data; - ptrdiff_t i, len; + ptrdiff_t i, used = search_regs_num_used () + 1; + ptrdiff_t len = used * 2; if (!NILP (reseat)) for (tail = reuse; CONSP (tail); tail = XCDR (tail)) @@ -2885,10 +2909,9 @@ DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0, prev = Qnil; USE_SAFE_ALLOCA; - SAFE_NALLOCA (data, 1, 2 * search_regs.num_regs + 1); + SAFE_NALLOCA (data, 1, 2 * used + 1); - len = 0; - for (i = 0; i < search_regs.num_regs; i++) + for (i = 0; i < used; i++) { ptrdiff_t start = search_regs.start[i]; if (start >= 0) @@ -2913,8 +2936,6 @@ DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0, else /* last_thing_searched must always be Qt, a buffer, or Qnil. */ emacs_abort (); - - len = 2 * i + 2; } else data[2 * i] = data[2 * i + 1] = Qnil; --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 23 07:52:23 2024 Received: (at 73018) by debbugs.gnu.org; 23 Sep 2024 11:52:23 +0000 Received: from localhost ([127.0.0.1]:43358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sshc6-0000Us-Tr for submit@debbugs.gnu.org; Mon, 23 Sep 2024 07:52:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38752) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sshc3-0000UZ-LW for 73018@debbugs.gnu.org; Mon, 23 Sep 2024 07:52:21 -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 1sshbX-0007qz-OU; Mon, 23 Sep 2024 07:51:48 -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=NpY1ZPHuoL8PRCKKxaX4cwZdoGdl+YdZW6SMmKyNcJ8=; b=PQ4rE8h5pz50 Orm2uMhv43lCvgR88mxxEUgkiGwQ5rs5BMBoN+91ezE73yjZ931wyw7h22a93l9Kq08G9yjcwiLk3 CFVovqckZ7lue8auvKS5ILfdJS2c/W/OJws+Cvnf0MVyMw7MFUIH3Cpx/YjyTquu1nVK3vzx2Ity3 RdneEjkqaUYfRJQ7Jehti8I7kilQkxURwwCscydPqPCEHMA2nSpyk6oPjA8UQXugL0gUILnwvcBYI Xm2wb9RfHBiJ8QxJ5KzdZitHnQaRELX5gCrjSZeqfho93C4Sq+Lpt4n51RvLyOBBoFUV4agBEDUMj uJ0jhcdbEECi263S+xlpkA==; Date: Mon, 23 Sep 2024 14:51:44 +0300 Message-Id: <865xqmh9kf.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sun, 22 Sep 2024 23:43:03 -0400) Subject: Re: bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer References: <20240904.080321.1100373523429404965.enometh@meer.net> <87seug85hh.fsf@web.de> <86y147gzx0.fsf@mail.linkov.net> <874j6uz4d8.fsf@web.de> <86ed5yujq3.fsf@mail.linkov.net> <87v7z9rnrp.fsf@web.de> <87o750dats.fsf@web.de> <868qw2ruv3.fsf@mail.linkov.net> <87bk0w511c.fsf@web.de> <86a5gg7nrs.fsf@mail.linkov.net> <86tteo3wmh.fsf@mail.linkov.net> <86h6aih8i9.fsf@gnu.org> <86zfo9c64h.fsf@gnu.org> <86ldzl4agb.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73018 Cc: michael_heerdegen@web.de, enometh@meer.net, 73018@debbugs.gnu.org, yantar92@posteo.net, 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: Stefan Monnier > Cc: michael_heerdegen@web.de, enometh@meer.net, yantar92@posteo.net, > 73018-done@debbugs.gnu.org, juri@linkov.net > Date: Sun, 22 Sep 2024 23:43:03 -0400 > > > bug#65451, sigh). I did install the change you suggested on master. > > And with that, I'm closing this bug. > > BTW, for `master` I think a better change is to fix the check. > E.g. with the patch below. Feel free to install, if you are satisfied with this. From unknown Fri Aug 15 01:54:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 22 Oct 2024 11:24:06 +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