Adjust thumbs to new rename-file behavior

* etc/NEWS: Mention this.
* lisp/thumbs.el (thumbs-rename-images): Treat the destination
as special only if it is a directory name.  When there is
a marked list, turn the destination into a directory name
if it is not already.
This commit is contained in:
Paul Eggert 2017-09-10 22:28:08 -07:00
parent 74b8615fcc
commit 2aa0288259
2 changed files with 5 additions and 12 deletions

View file

@ -1287,7 +1287,7 @@ can be written as (rename-file C (file-name-as-directory D)), a
formulation portable to both older and newer versions of Emacs.
Affected functions include add-name-to-file, copy-directory,
copy-file, format-write-file, gnus-copy-file, make-symbolic-link,
rename-file, and write-file.
rename-file, thumbs-rename-images, and write-file.
* Lisp Changes in Emacs 26.1

View file

@ -523,23 +523,16 @@ Open another window."
(interactive "FRename to file or directory: ")
(let ((files (or thumbs-marked-list (list (thumbs-current-image))))
failures)
(if (and (not (file-directory-p newfile))
thumbs-marked-list)
(if (file-exists-p newfile)
(error "Renaming marked files to file name `%s'" newfile)
(make-directory newfile t)))
(when thumbs-marked-list
(make-directory newfile t)
(setq newfile (file-name-as-directory newfile)))
(if (yes-or-no-p (format "Really rename %d files? " (length files)))
(let ((thumbs-file-list (thumbs-file-alist))
(inhibit-read-only t))
(dolist (file files)
(let (failure)
(condition-case ()
(if (file-directory-p newfile)
(rename-file file
(expand-file-name
(file-name-nondirectory file)
newfile))
(rename-file file newfile))
(rename-file file newfile)
(file-error (setq failure t)
(push file failures)))
(unless failure