bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49124: Wdired doesn't like re-search-forward/replace-match


From: Michael Heerdegen
Subject: bug#49124: Wdired doesn't like re-search-forward/replace-match
Date: Sun, 20 Jun 2021 03:28:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eduardo Ochs <eduardoochs@gmail.com> writes:

> Here's how to see the bug in action. Define `foo' by executing this
> defun:
>
>   (defun foo (s e)
>     "Replace all `a's by `b's in the region."
>     (interactive "r")
>     (save-excursion
>       (save-restriction
>         (narrow-to-region s e)
>         (goto-char (point-min))
>         (while (re-search-forward "a" nil 'noerror)
>           (replace-match "b" 'fixedcase 'literal)))))
> [...]

I can reproduce the issue.  The culprit seems to be `narrow-to-region'
which seems to confuse the functions wdired now installs in the before
and/or after change hooks (they expect at least complete lines) --
because this version:

(defun foo (s e)
  "Replace all `a's by `b's in the region."
  (interactive "r")
  (save-excursion
    (save-restriction
      ;; (narrow-to-region s e)
      (goto-char s)
      (while (re-search-forward "a" e 'noerror)
        (replace-match "b" 'fixedcase 'literal)))))

works as expected.

I guess we should just temporarily `widen' in these functions.

Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]