]> code.delx.au - gnu-emacs/blobdiff - lisp/wdired.el
Fix w32 memory-management problem when extending buffer text
[gnu-emacs] / lisp / wdired.el
index c72e134b401d7a521c8c8e95c2063e203d9cd110..16ea67dba5651e00f653d63c7fcb2f86a451ae9f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; wdired.el --- Rename files editing their names in dired buffers
 
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
 ;; Filename: wdired.el
 ;; Author: Juan León Lahoz García <juanleon1@gmail.com>
@@ -294,14 +294,15 @@ or \\[wdired-abort-changes] to abort changes")))
       (put-text-property b-protection (point-max) 'read-only t))))
 
 ;; This code is a copy of some dired-get-filename lines.
-(defsubst wdired-normalize-filename (file)
-  (setq file
-       ;; FIXME: shouldn't we check for a `b' argument or somesuch before
-       ;; doing such unquoting?  --Stef
-       (read (concat
-              "\"" (replace-regexp-in-string
-                    "\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file)
-              "\"")))
+(defsubst wdired-normalize-filename (file unquotep)
+  (when unquotep
+    (setq file
+          ;; FIXME: shouldn't we check for a `b' argument or somesuch before
+          ;; doing such unquoting?  --Stef
+          (read (concat
+                 "\"" (replace-regexp-in-string
+                       "\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file)
+                 "\""))))
   (and file buffer-file-coding-system
        (not file-name-coding-system)
        (not default-file-name-coding-system)
@@ -329,7 +330,8 @@ non-nil means return old filename."
          ;; deletion.
          (setq end (next-single-property-change beg 'end-name))
          (setq file (buffer-substring-no-properties (1+ beg) end)))
-       (and file (setq file (wdired-normalize-filename file))))
+       ;; Don't unquote the old name, it wasn't quoted in the first place
+        (and file (setq file (wdired-normalize-filename file (not old)))))
       (if (or no-dir old)
          file
        (and file (> (length file) 0)
@@ -494,8 +496,8 @@ non-nil means return old filename."
                                        overwrite))
                 (error
                  (setq errors (1+ errors))
-                 (dired-log (concat "Rename `" file-ori "' to `"
-                                    file-new "' failed:\n%s\n")
+                 (dired-log "Rename `%s' to `%s' failed:\n%s\n"
+                            file-ori file-new
                             err)))))))))
     errors))
 
@@ -627,7 +629,7 @@ If OLD, return the old target.  If MOVE, move point before it."
            (setq end (next-single-property-change beg 'end-link))
            (setq target (buffer-substring-no-properties (1+ beg) end)))
          (if move (goto-char (1- beg)))))
-    (and target (wdired-normalize-filename target))))
+    (and target (wdired-normalize-filename target t))))
 
 (declare-function make-symbolic-link "fileio.c")
 
@@ -651,8 +653,8 @@ If OLD, return the old target.  If MOVE, move point before it."
                (substitute-in-file-name link-to-new) link-from))
           (error
            (setq errors (1+ errors))
-           (dired-log (concat "Link `" link-from "' to `"
-                              link-to-new "' failed:\n%s\n")
+           (dired-log "Link `%s' to `%s' failed:\n%s\n"
+                      link-from link-to-new
                       err)))))
     (cons changes errors)))
 
@@ -666,7 +668,7 @@ If OLD, return the old target.  If MOVE, move point before it."
             (funcall command 1)
             (setq arg (1- arg)))
         (error
-         (if (forward-word)
+         (if (forward-word-strictly)
             ;; Skip any non-word characters to avoid triggering a read-only
             ;; error which would cause skipping the next word characters too.
             (skip-syntax-forward "^w")
@@ -837,11 +839,11 @@ Like original function but it skips read-only words."
               (unless (equal 0 (process-file dired-chmod-program
                                             nil nil nil perm-tmp filename))
                 (setq errors (1+ errors))
-                (dired-log (concat dired-chmod-program " " perm-tmp
-                                   " `" filename "' failed\n\n"))))
+                (dired-log "%s %s `%s' failed\n\n"
+                           dired-chmod-program perm-tmp filename)))
           (setq errors (1+ errors))
-          (dired-log (concat "Cannot parse permission `" perms-new
-                             "' for file `" filename "'\n\n"))))
+          (dired-log "Cannot parse permission `%s' for file `%s'\n\n"
+                     perms-new filename)))
       (goto-char (next-single-property-change (1+ (point)) prop-wanted
                                              nil (point-max))))
     (cons changes errors)))
@@ -849,7 +851,6 @@ Like original function but it skips read-only words."
 (provide 'wdired)
 
 ;; Local Variables:
-;; coding: utf-8
 ;; byte-compile-dynamic: t
 ;; End: