[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/wfnames b900a3835d 44/98: Merge branch 'devel' into main
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/wfnames b900a3835d 44/98: Merge branch 'devel' into main |
Date: |
Tue, 8 Aug 2023 04:01:22 -0400 (EDT) |
branch: elpa/wfnames
commit b900a3835ddc0ee12dba3c119a82511ff4198880
Merge: 750c1370c6 f510d716b6
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Merge branch 'devel' into main
---
wfnames.el | 61 ++++++++++++++++++++++++++-----------------------------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/wfnames.el b/wfnames.el
index 94a01671ed..80176450ed 100644
--- a/wfnames.el
+++ b/wfnames.el
@@ -42,11 +42,11 @@
"A mode to edit filenames."
:group 'wfnames)
-(defcustom wfnames-create-parent-directories nil
+(defcustom wfnames-create-parent-directories t
"Create parent directories when non nil."
:type 'boolean)
-(defcustom wfnames-interactive-rename nil
+(defcustom wfnames-interactive-rename t
"Ask confirmation when overwriting."
:type 'boolean)
@@ -119,6 +119,12 @@ Special commands:
(set (make-local-variable 'wfnames-old-files) files)
(funcall display-fn wfnames-buffer)))
+(defun wfnames-ask-for-overwrite (file)
+ (or (null wfnames-interactive-rename)
+ (y-or-n-p
+ (format "File `%s' exists, overwrite? "
+ file))))
+
(defun wfnames-commit-buffer ()
(interactive)
(let ((renamed 0) (skipped 0) delayed)
@@ -129,39 +135,17 @@ Special commands:
(let* ((beg (point-at-bol))
(end (point-at-eol))
(old (get-text-property (point) 'old-name))
- (new (buffer-substring-no-properties beg end)))
+ (new (buffer-substring-no-properties beg end))
+ ow)
(unless (string= old new) ; not modified, skip.
- (cond (;; New file exists and is one of the
- ;; next files to rename, make a temp
- ;; file of OLD and assign this temp
- ;; file to OLD, then delay renaming
- ;; to next turn.
+ (cond (;; New file exists, rename it to a
+ ;; temp file to put it out of the way
+ ;; and delay real rename to next turn.
(and (file-exists-p new)
(member new wfnames-old-files)
(not (assoc new delayed)))
- ;; Maybe ask
- (if (or (null wfnames-interactive-rename)
- (y-or-n-p
- (format "File `%s' exists,
overwrite? "
- new)))
- (let ((tmpfile (make-temp-name old)))
- (push (cons new tmpfile) delayed)
- (rename-file new tmpfile))
- ;; Answer is no, skip.
- (add-text-properties
- beg end `(old-name ,new))
- (cl-incf skipped)))
- (;; New file exists but is not part of
- ;; the next files to rename, make a
- ;; temp file of NEW and delay renaming
- ;; to next turn.
- (and (file-exists-p new)
- (not (assoc new delayed)))
;; Maybe ask.
- (if (or (null wfnames-interactive-rename)
- (y-or-n-p
- (format "File `%s' exists,
overwrite? "
- new)))
+ (if (wfnames-ask-for-overwrite new)
(let ((tmpfile (make-temp-name new)))
(push (cons new tmpfile) delayed)
(rename-file new tmpfile))
@@ -169,17 +153,24 @@ Special commands:
(add-text-properties
beg end `(old-name ,new))
(cl-incf skipped)))
- (t ; Now really rename files.
+ ;; Now really rename files.
+ (t
+ (when (and (file-exists-p new)
+ (not (assoc new delayed)))
+ (setq ow t))
(when wfnames-create-parent-directories
;; Check if base directory of new exists.
(let ((basedir (file-name-directory
(directory-file-name
new))))
(unless (file-directory-p basedir)
(mkdir basedir 'parents))))
- (rename-file
- old (if (file-directory-p new)
- (file-name-as-directory new)
- new))
+ (let ((target (if (file-directory-p new)
+ (file-name-as-directory new)
+ new)))
+ (if (and ow (wfnames-ask-for-overwrite new))
+ (rename-file old target ow)
+ (and ow (cl-incf skipped))
+ (and (null ow) (rename-file old target))))
(add-text-properties beg end `(old-name ,new))
(let* ((assoc (assoc new delayed))
(tmp (cdr assoc)))
- [nongnu] elpa/wfnames 6a83cedcda 76/98: Update README, (continued)
- [nongnu] elpa/wfnames 6a83cedcda 76/98: Update README, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 17ef480cb6 78/98: Update README, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 8b5f71d68e 81/98: Fix email address, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 0804263fa2 84/98: Fix both README and Commentary, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames bf0a11c3bf 90/98: Use eval-when-compile to require cl-lib (cl-loop only), ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames e4d6097892 98/98: Use parents arg for make-directory, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames ea13dc903e 30/98: Remove helm-edit-marked in favor of wfnames, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 8028da5298 32/98: Fix headers, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 2df88fc6e8 19/98: Handle directory creation, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 0b27368bbf 24/98: Make interactive rename nil by default, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames b900a3835d 44/98: Merge branch 'devel' into main,
ELPA Syncer <=
- [nongnu] elpa/wfnames a820f2f899 51/98: Add faces for dir and symlinks and use them, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames ac15fab7d9 56/98: Add FIXME comment, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames aa2e25a8ad 63/98: Fix docstring, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 9b219d5704 71/98: Fix some faces, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 2fb2cdbc5f 61/98: Fix comment, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames adda3f3d5d 59/98: Avoid creating unneedlessly a temp var for deleting it afterward, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames ee195dbf42 26/98: Fix name prefixes, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 6ba0ccd65e 34/98: Remove hardcoded faces and helm face, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 09af7da3b2 37/98: Handle backup overwrite, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 750c1370c6 41/98: Merge branch 'devel' into main, ELPA Syncer, 2023/08/08