]> git.eshelyaron.com Git - emacs.git/commitdiff
When renaming a file with wdired move point with file and don't lose mark status...
authorMichael Heerdegen <michael_heerdegen@web.de>
Wed, 17 Oct 2012 09:11:49 +0000 (11:11 +0200)
committerMartin Rudalics <rudalics@gmx.at>
Wed, 17 Oct 2012 09:11:49 +0000 (11:11 +0200)
* wdired.el (wdired-old-marks): New variable.
(wdired-change-to-wdired-mode): Locally set wdired-old-marks.
(wdired-do-renames): Move point with renamed file and don't lose
mark status (Bug#11795).

lisp/ChangeLog
lisp/wdired.el

index 437f8d57c9a594528ca7c62984fce290343bb45e..5a5549332acc4bea0d558434046bb934011f6649 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-17  Michael Heerdegen <michael_heerdegen@web.de>  (tiny change)
+
+       * wdired.el (wdired-old-marks): New variable.
+       (wdired-change-to-wdired-mode): Locally set wdired-old-marks.
+       (wdired-do-renames): Move point with renamed file and don't lose
+       mark status (Bug#11795).
+
 2012-10-16  Juri Linkov  <juri@jurta.org>
 
        * replace.el (query-replace-help): Mention multi-buffer replacement
index b893e8f6f2b73754e79863ce40e660489c56c0fd..266d199338955c972fe4cb96226f0a191990dcc4 100644 (file)
@@ -180,7 +180,7 @@ program `dired-chmod-program', which must exist."
 (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,6 +221,8 @@ See `wdired-mode'."
     (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)
@@ -455,7 +457,8 @@ non-nil means return old filename."
               (push (cons tmp file-new) residue))))
          (t
           (setq progress t)
-          (let ((file-ori (car rename)))
+          (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
@@ -466,12 +469,17 @@ non-nil means return old filename."
               (condition-case err
                   (let ((dired-backup-overwrite nil))
                     (dired-rename-file file-ori file-new
-                                       overwrite))
+                                       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)))))))))
+                            err)
+                 (dired-add-entry file-ori old-mark)))))))))
     errors))