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

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

[nongnu] elpa/wfnames a0d1f99760 02/98: Fix overwriting


From: ELPA Syncer
Subject: [nongnu] elpa/wfnames a0d1f99760 02/98: Fix overwriting
Date: Tue, 8 Aug 2023 04:01:11 -0400 (EDT)

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

    Fix overwriting
---
 helm-edit-marked.el | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/helm-edit-marked.el b/helm-edit-marked.el
index 5f625968db..bccaba181c 100644
--- a/helm-edit-marked.el
+++ b/helm-edit-marked.el
@@ -55,10 +55,16 @@ Special commands:
 ;; /home/thierry/tmp/test005.txt
 
 
-;; /home/thierry/tmp/test005.txt
-;; /home/thierry/tmp/test004.txt
-;; /home/thierry/tmp/test003.txt
-;; /home/thierry/tmp/test002.txt
+;; /home/thierry/tmp/test001.txt => /home/thierry/tmp/test005.txt
+;; /home/thierry/tmp/test002.txt => /home/thierry/tmp/test004.txt
+;; /home/thierry/tmp/test004.txt => /home/thierry/tmp/test002.txt
+
+(setq helm-find-files-actions
+      (helm-append-at-nth
+       helm-find-files-actions
+       '(("Edit marked files" . helm-ff-edit-marked-files)) 2))
+
+(setq helm-source-find-files nil)
 
 (defun helm-ff-edit-marked-commit-buffer ()
   (interactive)
@@ -71,12 +77,18 @@ Special commands:
                             (new (buffer-substring-no-properties
                                   (point-at-bol) (point-at-eol))))
                         (unless (string= old new) ; not modified.
-                          (if (file-exists-p new)
-                              (push new suspended)
+                          (if (and (file-exists-p new)
+                                   (not (assoc new suspended)))
+                              (let ((tmpfile (make-temp-name new)))
+                                (push (cons new tmpfile) suspended)
+                                (rename-file new tmpfile)
+                                (delete-region (point-at-bol) (point-at-eol))
+                                (insert (propertize new 'old-name tmpfile)))
                             (rename-file old new)
                             (add-text-properties
                              (point-at-bol) (point-at-eol) `(old-name ,new))
-                            (setq suspended (delete new suspended))
+                            (setq suspended
+                                  (delete (assoc new suspended) suspended))
                             (cl-incf renamed))))
                       (forward-line 1))
                     (when suspended (commit)))))



reply via email to

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