X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6ccc848cd85e75d77d6b11a46f5f23f860db9ff5..cd22663b8521f2cc34b260fc097e189428535b29:/lisp/wdired.el diff --git a/lisp/wdired.el b/lisp/wdired.el index 9851b2046d..c72e134b40 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -1,9 +1,9 @@ ;;; wdired.el --- Rename files editing their names in dired buffers -;; Copyright (C) 2004-2012 Free Software Foundation, Inc. +;; Copyright (C) 2004-2015 Free Software Foundation, Inc. ;; Filename: wdired.el -;; Author: Juan León Lahoz García +;; Author: Juan León Lahoz García ;; Version: 2.0 ;; Keywords: dired, environment, files, renaming @@ -73,8 +73,6 @@ ;;; Code: -(defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var - (require 'dired) (autoload 'dired-do-create-files-regexp "dired-aux") @@ -185,7 +183,8 @@ renamed by `dired-do-rename' and `dired-do-rename-regexp'." (define-key map [remap capitalize-word] 'wdired-capitalize-word) (define-key map [remap downcase-word] 'wdired-downcase-word) - map)) + map) + "Keymap used in `wdired-mode'.") (defvar wdired-mode-hook nil "Hooks run when changing to WDired mode.") @@ -239,8 +238,8 @@ See `wdired-mode'." (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) - 'wdired-isearch-filter-read-only) + (add-function :after-while (local 'isearch-filter-predicate) + #'wdired-isearch-filter-read-only) (use-local-map wdired-mode-map) (force-mode-line-update) (setq buffer-read-only nil) @@ -268,9 +267,8 @@ or \\[wdired-abort-changes] to abort changes"))) (defun wdired-isearch-filter-read-only (beg end) "Skip matches that have a read-only property." - (and (isearch-filter-visible beg end) - (not (text-property-not-all (min beg end) (max beg end) - 'read-only nil)))) + (not (text-property-not-all (min beg end) (max beg end) + 'read-only nil))) ;; Protect the buffer so only the filenames can be changed, and put ;; properties so filenames (old and new) can be easily found. @@ -399,6 +397,15 @@ non-nil means return old filename." (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 @@ non-nil means return old filename." (= (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 @@ non-nil means return old filename." (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 @@ non-nil means return old filename." (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 @@ non-nil means return old filename." (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)) @@ -851,7 +849,7 @@ Like original function but it skips read-only words." (provide 'wdired) ;; Local Variables: -;; coding: latin-1 +;; coding: utf-8 ;; byte-compile-dynamic: t ;; End: