GNU bug report logs - #49124
Wdired doesn't like re-search-forward/replace-match

Previous Next

Package: emacs;

Reported by: Eduardo Ochs <eduardoochs <at> gmail.com>

Date: Sun, 20 Jun 2021 00:34:02 UTC

Severity: normal

Tags: moreinfo, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 49124 <at> debbugs.gnu.org (full text, mbox):

From: Eduardo Ochs <eduardoochs <at> gmail.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 49124 <at> debbugs.gnu.org
Subject: Re: bug#49124: Wdired doesn't like re-search-forward/replace-match
Date: Sat, 19 Jun 2021 22:45:25 -0300
On Sat, 19 Jun 2021 at 22:28, Michael Heerdegen
<michael_heerdegen <at> web.de> wrote:
>
> Eduardo Ochs <eduardoochs <at> 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.

Hi Michael,

Is there a simple way to write a macro called, say,
`wdired-with-narrow-to-filename' that would narrow the buffer to the
editable portion of current line, evaluate some code, and on exit it
would tell wdired to reread the filename in that line, knowing that it
it may have been changed?

  Cheers & possibly thanks in advance =),
    Eduardo Ochs
    http://angg.twu.net/#eev




This bug report was last modified 3 years and 302 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.