From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#11795: 24.1.50; wdired: C-c C-c loses marks and positions of renamed files Date: Tue, 09 Oct 2012 02:41:42 +0200 Message-ID: <87d30siiih.fsf@web.de> References: <87r4t1sk9o.fsf@web.de> <87sjdhily5@ch.ristopher.com> <06AF8E7E174A4F768ADB2B901755EA3C@us.oracle.com> <871ul0bymm@ch.ristopher.com> <87zk7ozman.fsf@web.de> <87d34kfxa3@ch.ristopher.com> <87d34kzcr8.fsf@web.de> <873958b2cm.fsf@web.de> <4FF40A79.5000707@gmx.at> <87ipcbmt6d.fsf@web.de> <50348571.1070605@gmx.at> <87bohtlo9d@ch.ristopher.com> <87a9xdoet6.fsf@web.de> <506C01ED.9000906@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1349743360 19641 80.91.229.3 (9 Oct 2012 00:42:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Oct 2012 00:42:40 +0000 (UTC) Cc: christopher@ristopher.com, 11795@debbugs.gnu.org, heerdegen.michael@googlemail.com To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 09 02:42:46 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 1TLNuF-0001el-V8 for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Oct 2012 02:42:44 +0200 Original-Received: from localhost ([::1]:56317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLNu9-0001wj-RO for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Oct 2012 20:42:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLNu6-0001w3-7l for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 20:42:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLNu4-00058A-JZ for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 20:42:34 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLNu4-000584-FU for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 20:42:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TLNuY-0001oJ-5f for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 20:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Oct 2012 00:43: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.13497433386899 (code B ref 11795); Tue, 09 Oct 2012 00:43:01 +0000 Original-Received: (at 11795) by debbugs.gnu.org; 9 Oct 2012 00:42:18 +0000 Original-Received: from localhost ([127.0.0.1]:34422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TLNtp-0001nE-GW for submit@debbugs.gnu.org; Mon, 08 Oct 2012 20:42:17 -0400 Original-Received: from mout.web.de ([212.227.17.11]:54584) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TLNtl-0001mw-Nt for 11795@debbugs.gnu.org; Mon, 08 Oct 2012 20:42:15 -0400 Original-Received: from drachen.dragon ([89.204.130.248]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MRlIL-1SwokQ3nNh-00SzkY; Tue, 09 Oct 2012 02:41:37 +0200 In-Reply-To: <506C01ED.9000906@gmx.at> (martin rudalics's message of "Wed, 03 Oct 2012 11:14:21 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-Provags-ID: V02:K0:ENT8Y34iWACYrgAr70h0X+TzRP2Yk5Mqu78fhUUzbPB DXQMync2Thk8bJGWj3umig3R0ojX4gvB8NnsTGguPshH40es55 tpyi1pu+8D809CsKd5gyaf7BIn57+vfpBfrcWErY0lJURxMz95 y9VEibFWHXAsL5S4qSHiqBH8faYR7Fk0LNjo5HPoyMg2nXANev u3lLBmarngcOqkbq+aQ+574elNMx1yF86T+95NFswE= 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 (newer, 2) 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:65410 Archived-At: --=-=-= Content-Type: text/plain Hello Martin, > Any chances for a fix to this in the next days? Sorry for the delay. The patch we had so far for this had several problems: - It sometimes failed to collect file marks because it did that when the buffer had already been modified. - It failed to restore the marks of files that couldn't be renamed (e.g. in read-only dirs) - It didn't propagate the name changes to other dired buffers I created a new fix that should take care of these problems. I wanted to make some more sanity tests today, unfortunately I'm ill and don't feel well. I'll try to do this tomorrow. So, this is the new patch: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=wdired.patch *** /home/micha/today/wdired.el 2012-10-09 02:27:03.638708806 +0200 --- /home/micha/today/wdired-new.el 2012-10-09 02:24:13.498706008 +0200 *************** *** 180,186 **** (defvar wdired-col-perm) ;; Column where the permission bits start (defvar wdired-old-content) (defvar wdired-old-point) ! (defun wdired-mode () "Writable Dired (WDired) mode. --- 180,186 ---- (defvar wdired-col-perm) ;; Column where the permission bits start (defvar wdired-old-content) (defvar wdired-old-point) ! (defvar wdired-old-marks) (defun wdired-mode () "Writable Dired (WDired) mode. *************** *** 221,226 **** --- 221,228 ---- (error "Not a Dired buffer")) (set (make-local-variable 'wdired-old-content) (buffer-substring (point-min) (point-max))) + (set (make-local-variable 'wdired-old-marks) + (dired-remember-marks (point-min) (point-max))) (set (make-local-variable 'wdired-old-point) (point)) (set (make-local-variable 'query-replace-skip-read-only) t) (set (make-local-variable 'isearch-filter-predicate) *************** *** 430,477 **** (let* ((rename (pop renames)) (file-new (cdr rename))) (cond ! ((rassoc file-new renames) ! (error "Trying to rename 2 files to the same name")) ! ((assoc file-new renames) ! ;; Renaming to a file name that already exists but will itself be ! ;; renamed as well. Let's wait until that one gets renamed. ! (push rename residue)) ! ((and (assoc file-new residue) ! ;; Make sure the file really exists: if it doesn't it's ! ;; not really a conflict. It might be a temp-file generated ! ;; specifically to break a circular renaming. ! (file-exists-p file-new)) ! ;; Renaming to a file name that already exists, needed to be renamed, ! ;; but whose renaming could not be performed right away. ! (if (or progress renames) ! ;; There's still a chance the conflict will be resolved. ! (push rename residue) ! ;; We have not made any progress and we've reached the end of ! ;; the renames, so we really have a circular conflict, and we ! ;; have to forcefully break the cycle. ! (message "Circular renaming: using temporary file name") ! (let ((tmp (make-temp-name file-new))) ! (push (cons (car rename) tmp) renames) ! (push (cons tmp file-new) residue)))) ! (t ! (setq progress t) ! (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 ! ;; dired-backup-overwrite is locally bound, ! ;; dired-backup-overwrite won't be initialized. ! ;; So we must ensure dired-aux is loaded. ! (require 'dired-aux) ! (condition-case err ! (let ((dired-backup-overwrite nil)) ! (dired-rename-file file-ori file-new ! overwrite)) ! (error ! (setq errors (1+ errors)) ! (dired-log (concat "Rename `" file-ori "' to `" ! file-new "' failed:\n%s\n") ! err))))))))) errors)) --- 432,485 ---- (let* ((rename (pop renames)) (file-new (cdr rename))) (cond ! ((rassoc file-new renames) ! (error "Trying to rename 2 files to the same name")) ! ((assoc file-new renames) ! ;; Renaming to a file name that already exists but will itself be ! ;; renamed as well. Let's wait until that one gets renamed. ! (push rename residue)) ! ((and (assoc file-new residue) ! ;; Make sure the file really exists: if it doesn't it's ! ;; not really a conflict. It might be a temp-file generated ! ;; specifically to break a circular renaming. ! (file-exists-p file-new)) ! ;; Renaming to a file name that already exists, needed to be renamed, ! ;; but whose renaming could not be performed right away. ! (if (or progress renames) ! ;; There's still a chance the conflict will be resolved. ! (push rename residue) ! ;; We have not made any progress and we've reached the end of ! ;; the renames, so we really have a circular conflict, and we ! ;; have to forcefully break the cycle. ! (message "Circular renaming: using temporary file name") ! (let ((tmp (make-temp-name file-new))) ! (push (cons (car rename) tmp) 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)))) ! (if wdired-use-interactive-rename ! (wdired-search-and-rename file-ori file-new) ! ;; If dired-rename-file autoloads dired-aux while ! ;; dired-backup-overwrite is locally bound, ! ;; dired-backup-overwrite won't be initialized. ! ;; So we must ensure dired-aux is loaded. ! (require 'dired-aux) ! (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 (if (integerp dired-keep-marker-rename) ! dired-keep-marker-rename ! old-mark))) ! (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))))))))) errors)) --=-=-= Content-Type: text/plain Regards, Michael. --=-=-=--