bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer

2024-09-03 Thread Madhu
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)
>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



bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer

2024-09-04 Thread Madhu
No problem,
*  Michael Heerdegen  <87seug85hh@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.


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()
(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")


bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer

2024-09-04 Thread Madhu
*  Madhu  
<20240904.142831.1583368143272051709.enom...@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)






bug#73018: 31.0.50; wdired + replace-regexp only modifies the visible portion of the buffer

2024-09-05 Thread Madhu
*  Michael Heerdegen  <874j6uz4d8@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