emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/wfnames 8e549f1e6a 16/98: Fix the logic in commit fn


From: ELPA Syncer
Subject: [nongnu] elpa/wfnames 8e549f1e6a 16/98: Fix the logic in commit fn
Date: Tue, 8 Aug 2023 04:01:13 -0400 (EDT)

branch: elpa/wfnames
commit 8e549f1e6aa0d97bd4e98e09c2ca8ea7cbca90b9
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Fix the logic in commit fn
---
 helm-edit-marked.el | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/helm-edit-marked.el b/helm-edit-marked.el
index 52bf944a0c..15c30fe084 100644
--- a/helm-edit-marked.el
+++ b/helm-edit-marked.el
@@ -82,18 +82,31 @@ Special commands:
                              (old (get-text-property (point) 'old-name))
                              (new (buffer-substring-no-properties beg end)))
                         (unless (string= old new) ; not modified.
-                          (if (and (file-exists-p new)
-                                   (not (assoc new delayed)))
-                              (let ((tmpfile (make-temp-name new)))
-                                (push (cons new tmpfile) delayed)
-                                (rename-file new tmpfile)
-                                (add-text-properties beg end `(old-name 
,tmpfile)))
-                            (rename-file old new)
-                            (add-text-properties beg end `(old-name ,new))
-                            (setq delayed
-                                  (delete (assoc new delayed) delayed))
-                            (cl-incf renamed))))
-                      (forward-line 1))
+                          (cond ((and (file-exists-p new)
+                                      (member new
+                                              helm-ff--edit-marked-old-files)
+                                      (not (assoc new delayed)))
+                                 (let ((tmpfile (make-temp-name old)))
+                                   (push (cons new tmpfile) delayed)
+                                   (rename-file old tmpfile)
+                                   (add-text-properties
+                                    beg end `(old-name ,tmpfile))))
+                                ((and (file-exists-p new)
+                                      (not (assoc new delayed)))
+                                 (let ((tmpfile (make-temp-name new)))
+                                   (push (cons new tmpfile) delayed)
+                                   (rename-file new tmpfile)))
+                                (t
+                                 (rename-file old new)
+                                 (add-text-properties beg end `(old-name ,new))
+                                 (let* ((assoc (assoc new delayed))
+                                        (tmp   (cdr assoc)))
+                                   (when (and tmp (file-exists-p tmp))
+                                     (delete-file tmp))
+                                   (setq delayed
+                                         (delete assoc delayed)))
+                                 (cl-incf renamed))))
+                        (forward-line 1)))
                     (when delayed (commit)))))
       (commit)
       (message "* Renamed %s file(s) " renamed)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]