From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#11795: 24.1.50; wdired: C-c C-c loses marks and positions of renamed files Date: Thu, 22 Nov 2012 11:12:12 +0200 Organization: JURTA Message-ID: <87txsiuhkl.fsf@mail.jurta.org> References: <87r4t1sk9o.fsf@web.de> <87sjdhily5@ch.ristopher.com> <06AF8E7E174A4F768ADB2B901755EA3C@us.oracle.com> <87sj95ad3l.fsf@mail.jurta.org> <87vce0xah6.fsf@web.de> <87a9v85l3p.fsf@mail.jurta.org> <87pq44rs4z.fsf@web.de> <87ip9wf08t.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1353575934 31943 80.91.229.3 (22 Nov 2012 09:18:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Nov 2012 09:18:54 +0000 (UTC) To: 11795@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 22 10:19:06 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TbSw3-0004gw-0T for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Nov 2012 10:19:03 +0100 Original-Received: from localhost ([::1]:34071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbSvs-0007hZ-Em for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Nov 2012 04:18:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:34760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbSvp-0007hO-VJ for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2012 04:18:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbSvi-0006vN-Ib for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2012 04:18:49 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbSvi-0006vJ-FQ for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2012 04:18:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TbSwz-0000Jn-J0 for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2012 04:20:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Nov 2012 09:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11795 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11795-submit@debbugs.gnu.org id=B11795.13535759951202 (code B ref 11795); Thu, 22 Nov 2012 09:20:01 +0000 Original-Received: (at 11795) by debbugs.gnu.org; 22 Nov 2012 09:19:55 +0000 Original-Received: from localhost ([127.0.0.1]:60289 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TbSws-0000JK-KN for submit@debbugs.gnu.org; Thu, 22 Nov 2012 04:19:54 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:55551 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TbSwq-0000J8-3C; Thu, 22 Nov 2012 04:19:53 -0500 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 94FF646FA013; Thu, 22 Nov 2012 01:18:30 -0800 (PST) In-Reply-To: <87ip9wf08t.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 27 Oct 2012 17:38:58 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:67306 Archived-At: reopen 11795 stop This bug is a regression against Emacs 23.1+. Actually I found out that Christopher already proposed a patch that fixes this bug. I see no reason not to use it. I propose to do this on the Emacs-24 release branch before the pretest: to revert the ill-behaved part of revno:110564 and install Christopher's patch that works correctly in my tests and has no bad effects caused by unnecessary direct operations on the dired buffer. Below is a complete patch adapted for the Emacs-24 release branch: === modified file 'lisp/wdired.el' --- lisp/wdired.el 2012-10-27 09:17:14 +0000 +++ lisp/wdired.el 2012-11-22 09:09:30 +0000 @@ -399,6 +397,15 @@ (defun wdired-finish-edit () (setq changes t) (if (not file-new) ;empty filename! (push file-old files-deleted) + (when wdired-keep-marker-rename + (let ((mark (cond ((integerp wdired-keep-marker-rename) + wdired-keep-marker-rename) + (wdired-keep-marker-rename + (cdr (assoc file-old wdired-old-marks))) + (t nil)))) + (when mark + (push (cons (substitute-in-file-name file-new) mark) + wdired-old-marks)))) (push (cons file-old (substitute-in-file-name file-new)) files-renamed)))) (forward-line -1))) @@ -416,7 +423,9 @@ (defun wdired-finish-edit () (= (length files-renamed) 1)) (setq dired-directory (cdr (car files-renamed)))) ;; Re-sort the buffer. - (revert-buffer)) + (revert-buffer) + (let ((inhibit-read-only t)) + (dired-mark-remembered wdired-old-marks))) (let ((inhibit-read-only t)) (remove-text-properties (point-min) (point-max) '(old-name nil end-name nil old-link nil @@ -430,8 +439,6 @@ (defun wdired-finish-edit () (set-buffer-modified-p nil) (setq buffer-undo-list nil)) -(declare-function dired-add-entry "dired-aux" (filename &optional marker-char relative)) - (defun wdired-do-renames (renames) "Perform RENAMES in parallel." (let ((residue ()) @@ -473,8 +480,7 @@ (defun wdired-do-renames (renames) (push (cons tmp file-new) residue)))) (t (setq progress t) - (let* ((file-ori (car rename)) - (old-mark (cdr (assoc file-ori wdired-old-marks)))) + (let* ((file-ori (car rename))) (if wdired-use-interactive-rename (wdired-search-and-rename file-ori file-new) ;; If dired-rename-file autoloads dired-aux while @@ -485,20 +491,12 @@ (defun wdired-do-renames (renames) (condition-case err (let ((dired-backup-overwrite nil)) (dired-rename-file file-ori file-new - overwrite) - (dired-remove-file file-ori) - (dired-add-file - file-new - (cond ((integerp wdired-keep-marker-rename) - wdired-keep-marker-rename) - (wdired-keep-marker-rename old-mark) - (t nil)))) + overwrite)) (error (setq errors (1+ errors)) (dired-log (concat "Rename `" file-ori "' to `" file-new "' failed:\n%s\n") - err) - (dired-add-entry file-ori old-mark))))))))) + err))))))))) errors))