unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eduardo Ochs <eduardoochs@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 49124@debbugs.gnu.org
Subject: bug#49124: Wdired doesn't like re-search-forward/replace-match
Date: Sat, 19 Jun 2021 22:45:25 -0300	[thread overview]
Message-ID: <CADs++6hieoKKpY=YrYPMMX5g2Kb+17sXOJWQS4oftPXBfSZWGw@mail.gmail.com> (raw)
In-Reply-To: <87o8c1b9yf.fsf@web.de>

On Sat, 19 Jun 2021 at 22:28, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
>
> 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.

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





  reply	other threads:[~2021-06-20  1:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20  0:33 bug#49124: Wdired doesn't like re-search-forward/replace-match Eduardo Ochs
2021-06-20  1:28 ` Michael Heerdegen
2021-06-20  1:45   ` Eduardo Ochs [this message]
2021-06-20  2:12     ` Michael Heerdegen
2021-06-21 13:11       ` Lars Ingebrigtsen
2021-06-21 21:59         ` Michael Heerdegen
2021-07-19 17:04           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADs++6hieoKKpY=YrYPMMX5g2Kb+17sXOJWQS4oftPXBfSZWGw@mail.gmail.com' \
    --to=eduardoochs@gmail.com \
    --cc=49124@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).