From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eduardo Ochs Newsgroups: gmane.emacs.bugs Subject: bug#49124: Wdired doesn't like re-search-forward/replace-match Date: Sat, 19 Jun 2021 22:45:25 -0300 Message-ID: References: <87o8c1b9yf.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30048"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49124@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 20 03:46:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lumXN-0007cs-Uz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 03:46:13 +0200 Original-Received: from localhost ([::1]:33946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lumXM-0001Vi-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Jun 2021 21:46:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lumXC-0001TQ-Lp for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 21:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lumXC-0007G2-Du for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 21:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lumXC-0005Dv-5B for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 21:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eduardo Ochs Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Jun 2021 01:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49124 X-GNU-PR-Package: emacs Original-Received: via spool by 49124-submit@debbugs.gnu.org id=B49124.162415354620057 (code B ref 49124); Sun, 20 Jun 2021 01:46:02 +0000 Original-Received: (at 49124) by debbugs.gnu.org; 20 Jun 2021 01:45:46 +0000 Original-Received: from localhost ([127.0.0.1]:32872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lumWv-0005DR-Nv for submit@debbugs.gnu.org; Sat, 19 Jun 2021 21:45:45 -0400 Original-Received: from mail-pf1-f180.google.com ([209.85.210.180]:34681) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lumWt-0005DB-AL for 49124@debbugs.gnu.org; Sat, 19 Jun 2021 21:45:44 -0400 Original-Received: by mail-pf1-f180.google.com with SMTP id g6so10867036pfq.1 for <49124@debbugs.gnu.org>; Sat, 19 Jun 2021 18:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MXxMaWXyGjqiacEFpXsURlMEuPR0ZRXmj49gnlqzZdA=; b=UFQZIHXmbOayPjvf86SIXn1j9VTVNZ9iY/qbV3/kZG1u8JgQyxiDrJ6+krg11gEZFo KWIiRPkuVbiI7oM9oVf+rY31Wg5JBsUuWPmd2omCuHHkzh+qzrHKTAxWNalvxCs5z2p/ dSrOGu5t07RrIT+oeqgax8xJMeRscEVbYFNuf/jGlGvx5vd9hqQERtL9RoRBWnoFx+LO /kZVwnA1xxekGdwI86dHGwGsESMDtNi3kdCXjykDdC6ZMta6k4rTabR43+w5bXsgs6yR gZlpn9Stv3LmX9vcW25I1kw9FD6D3A3haOXBt4SmSixBuYssmBSSPH4IzkJLnfENbXge zX9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MXxMaWXyGjqiacEFpXsURlMEuPR0ZRXmj49gnlqzZdA=; b=soJLyw9opzRpUGx+13+VWVo2QOJN4zPKvDMt5z4oFMru+gyvg3drlMEwsrgWq1kzqV hfVi1jXR6qwL+RHYCdn11OvVCbcbGDsDZf8wnhc3wkcSTbaLjO+OAeI+XbBLyw1i9RCv bvQtvBg4nQikOLue++Jllns12yLljA8fyFpLiYcaDwBbaRlMjDQHFxpZDjcbYsMduwra Ldm+hvd7QCHmDwkXvRIEGAn7bSBBebNCgXvJJ7AtUpQ3gkcZjMBoIGxnVOMiL883hxww WVn5OdXBJ9kU3QRD8bcYvp2gQgIPA9504ciAmxlrZJCkma2iuxMaBp56N7eF/9A8QZco OOFg== X-Gm-Message-State: AOAM530IjNyMkysGKVPFnVuYNBGVgsJM0PggWyZjk7rnaG/zrGPVYHWT CwndKasyxRtnLOboxMAc6FWc9n2cfu+uKC9vdxY= X-Google-Smtp-Source: ABdhPJxLziC/IOetMnylivNWM1Et0j9XeZ77fN9xHzyjGFtLBdM9XhSrBG6EsqGzAMuD8wtD7CA6/TqwGqSMLTMXEE8= X-Received: by 2002:a63:d213:: with SMTP id a19mr17252273pgg.28.1624153537353; Sat, 19 Jun 2021 18:45:37 -0700 (PDT) In-Reply-To: <87o8c1b9yf.fsf@web.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:208780 Archived-At: On Sat, 19 Jun 2021 at 22:28, Michael Heerdegen wrote: > > Eduardo Ochs 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