From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#32173: 26.1; wdired: broken 'wdired-use-interactive-rename' Date: Fri, 20 Jul 2018 22:44:31 +0300 Message-ID: <83pnzhzo80.fsf@gnu.org> References: <87zhyrfgxu.fsf@delenn.bigo.ensc.de> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1532115834 28202 195.159.176.226 (20 Jul 2018 19:43:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Jul 2018 19:43:54 +0000 (UTC) Cc: 32173@debbugs.gnu.org To: Enrico Scholz Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 20 21:43:50 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgbJc-0007B8-A9 for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Jul 2018 21:43:48 +0200 Original-Received: from localhost ([::1]:49554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgbLi-00009b-Td for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Jul 2018 15:45:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgbKu-0007Zf-Mf for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 15:45:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgbKp-0005QY-2u for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 15:45:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fgbKo-0005Q1-U1 for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 15:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fgbKo-0003gF-D7 for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 15:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jul 2018 19:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32173 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32173-submit@debbugs.gnu.org id=B32173.153211588514113 (code B ref 32173); Fri, 20 Jul 2018 19:45:02 +0000 Original-Received: (at 32173) by debbugs.gnu.org; 20 Jul 2018 19:44:45 +0000 Original-Received: from localhost ([127.0.0.1]:49970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgbKX-0003fY-B3 for submit@debbugs.gnu.org; Fri, 20 Jul 2018 15:44:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgbKT-0003fJ-Hk for 32173@debbugs.gnu.org; Fri, 20 Jul 2018 15:44:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgbKK-0004xp-7P for 32173@debbugs.gnu.org; Fri, 20 Jul 2018 15:44:36 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgbKK-0004xh-3J; Fri, 20 Jul 2018 15:44:32 -0400 Original-Received: from [176.228.60.248] (port=2552 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fgbKJ-0006ye-Hl; Fri, 20 Jul 2018 15:44:31 -0400 In-reply-to: <87zhyrfgxu.fsf@delenn.bigo.ensc.de> (message from Enrico Scholz on Mon, 16 Jul 2018 15:28:29 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148747 Archived-At: > From: Enrico Scholz > Date: Mon, 16 Jul 2018 15:28:29 +0200 > > wdired seems to misbehave when 'wdired-use-interactive-rename' is > active: > > 1. create scratch directory with a file > > mkdir /tmp/test > cd /tmp/test > touch foo.c > > 2. start emacs > > LC_ALL=C emacs -Q -nw > > 3. set option above > > M-: (setq wdired-use-interactive-rename t) > > 4. go into the folder > > C-x C-f /tmp/test > > emacs will show > > | /tmp/test: > | total used in directory 0 available 4023272 > | drwxrwxr-x. 2 ensc ensc 60 Jul 16 15:16 . > | drwxrwxrwt. 18 root root 600 Jul 16 15:17 .. > | -rw-rw-r--. 1 ensc ensc 0 Jul 16 14:58 foo.c > > 5. enter wdired mode > > C-x C-q > > 6. replace 'foo' with 'test'; e.g. > > test M-d > > 7. commit it > > C-c C-c > > > ---> emacs asks > > | Move `c' to `test.c'? [Type yn!q or C-h] > > or > > | Move `.' to `test.c'? [Type yn!q or C-h] > > (seems to differ slightly when repeating step 6). Buffer content is > malformed too (first two lines are merged, or whitespace between time > and filename is removed). It looks like the code expects you to delete the entire original name and then type the new name from scratch, it doesn't expect to see part of the old file name unaltered. Does the patch below give good result? diff --git a/lisp/wdired.el b/lisp/wdired.el index bb60e77..13005cb 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -550,7 +550,11 @@ wdired-search-and-rename (progn (setq done t) (let ((inhibit-read-only t)) - (dired-move-to-filename) + ;; Can't use dired-move-to-filename, because editing + ;; the file names could have left the 'dired-filename' + ;; property only on part of the file name. + (re-search-forward directory-listing-before-filename-regexp + (line-end-position) t) (search-forward (wdired-get-filename t) nil t) (replace-match (file-name-nondirectory filename-ori) t t)) (dired-do-create-files-regexp