all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Enrico Scholz <enrico.scholz@ensc.de>
Cc: 32173@debbugs.gnu.org
Subject: bug#32173: 26.1; wdired: broken 'wdired-use-interactive-rename'
Date: Fri, 20 Jul 2018 22:44:31 +0300	[thread overview]
Message-ID: <83pnzhzo80.fsf@gnu.org> (raw)
In-Reply-To: <87zhyrfgxu.fsf@delenn.bigo.ensc.de> (message from Enrico Scholz on Mon, 16 Jul 2018 15:28:29 +0200)

> From: Enrico Scholz <enrico.scholz@ensc.de>
> 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





  parent reply	other threads:[~2018-07-20 19:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 13:28 bug#32173: 26.1; wdired: broken 'wdired-use-interactive-rename' Enrico Scholz
2018-07-18 16:23 ` Stephen Berman
2018-07-20 19:44 ` Eli Zaretskii [this message]
2018-07-21 10:48   ` Stephen Berman
2018-07-21 12:06     ` Eli Zaretskii
2018-07-21 12:19       ` Eli Zaretskii
2018-07-21 23:38       ` Stephen Berman
2018-07-26  7:54         ` Stephen Berman
2018-07-26 17:23           ` Eli Zaretskii
2018-07-27  7:09         ` Eli Zaretskii
2018-07-27 18:15           ` Stephen Berman
2018-07-27 20:59             ` Eli Zaretskii
2018-07-28 23:21               ` Stephen Berman
2018-08-08 10:04                 ` Stephen Berman

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

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

  git send-email \
    --in-reply-to=83pnzhzo80.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=32173@debbugs.gnu.org \
    --cc=enrico.scholz@ensc.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.