[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/wfnames adda3f3d5d 59/98: Avoid creating unneedlessly a te
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/wfnames adda3f3d5d 59/98: Avoid creating unneedlessly a temp var for deleting it afterward |
Date: |
Tue, 8 Aug 2023 04:01:34 -0400 (EDT) |
branch: elpa/wfnames
commit adda3f3d5d4248d55cc2eb8c4c9080620ac3d6f4
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Avoid creating unneedlessly a temp var for deleting it afterward
---
wfnames.el | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/wfnames.el b/wfnames.el
index be16c97eef..3fa7c7e001 100644
--- a/wfnames.el
+++ b/wfnames.el
@@ -35,8 +35,7 @@
;; Internal.
(defvar wfnames-buffer "*Wfnames*")
-(defvar wfnames-old-files nil)
-
+(defvar wfnames--modified nil)
(defgroup wfnames nil
"A mode to edit filenames."
@@ -84,7 +83,8 @@
Special commands:
\\{helm-ff-edit-mode-map}
"
- (add-hook 'after-change-functions #'wfnames-after-change-hook nil t))
+ (add-hook 'after-change-functions #'wfnames-after-change-hook nil t)
+ (make-local-variable 'wfnames--modified))
(defun wfnames-after-change-hook (beg end _len)
(with-current-buffer wfnames-buffer
@@ -98,6 +98,8 @@ Special commands:
ov face)
(setq face (if (file-exists-p new)
'wfnames-modified-exists 'wfnames-modified))
+ (setq-local wfnames--modified
+ (cons old (delete old wfnames--modified)))
(cl-loop for o in (overlays-in bol eol)
when (overlay-get o 'hff-changed)
return (setq ov o))
@@ -136,7 +138,6 @@ Special commands:
;; Go to beginning of basename on first line.
(while (re-search-forward "/" (point-at-eol) t))
(wfnames-mode)
- (set (make-local-variable 'wfnames-old-files) files)
(funcall display-fn wfnames-buffer)))
(defun wfnames-ask-for-overwrite (file)
@@ -165,15 +166,9 @@ Special commands:
;; delayed alist for next usage as
;; old [1].
(and (file-exists-p new)
- ;; FIXME: We should switch
- ;; directly to next clause
- ;; i.e. rename directly without
- ;; delaying when file to rename
- ;; is NOT part of the files to
- ;; rename, so the test below is
- ;; wrong, forcing to delete temp
- ;; file at end of clause 2.
- (member new wfnames-old-files)
+ ;; new is one of the old
+ ;; files about to be modified.
+ (member new wfnames--modified)
(not (assoc new delayed)))
;; Maybe ask.
(if (wfnames-ask-for-overwrite new)
@@ -206,16 +201,8 @@ Special commands:
;; Not an overwrite, do normal renaming.
(and (null ow) (rename-file old new)))
(add-text-properties beg end `(old-name ,new))
- (let* ((assoc (assoc new delayed))
- (tmp (cdr assoc)))
- ;; The temp file was created in
- ;; clause 1, delete it.
- (when (and tmp (file-exists-p tmp))
- (if (file-directory-p tmp)
- (delete-directory tmp t)
- (delete-file tmp)))
- (setq delayed
- (delete assoc delayed)))
+ (setq delayed
+ (delete (assoc new delayed) delayed))
(cl-incf renamed))))
(forward-line 1)))
(when delayed (commit)))))
- [nongnu] elpa/wfnames ea13dc903e 30/98: Remove helm-edit-marked in favor of wfnames, (continued)
- [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, 2023/08/08
- [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 <=
- [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
- [nongnu] elpa/wfnames 6f13e86c85 48/98: Fix renaming directories behavior, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames d632731f2e 50/98: Go to beginning of basename on first line, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames a707b9d073 72/98: Add binding for CAP, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 6899da10b2 75/98: Modify revert binding, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 8d267316e8 83/98: Minor fixes in headers and keep requiring cl-lib as always, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 14cd7e7108 87/98: Ensure we have not an empty line at point, ELPA Syncer, 2023/08/08