[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/wfnames 860512b33c 58/98: Merge branch 'devel' into main
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/wfnames 860512b33c 58/98: Merge branch 'devel' into main |
Date: |
Tue, 8 Aug 2023 04:01:32 -0400 (EDT) |
branch: elpa/wfnames
commit 860512b33c577c8f6b56dce5b614590756e38984
Merge: b900a3835d b050bdabba
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Merge branch 'devel' into main
---
wfnames.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 53 insertions(+), 14 deletions(-)
diff --git a/wfnames.el b/wfnames.el
index 80176450ed..be16c97eef 100644
--- a/wfnames.el
+++ b/wfnames.el
@@ -50,6 +50,9 @@
"Ask confirmation when overwriting."
:type 'boolean)
+(defvar wfnames-after-commit-hook nil)
+
+
(defface wfnames-modified '((t :background "LightBlue"))
"Face used when filename is modified.")
@@ -58,10 +61,19 @@
(defface wfnames-files '((t :foreground "RoyalBlue"))
"Face used to display filenames in wfnames buffer.")
+
+(defface wfnames-dir '((t :background "White" :foreground "red"))
+ "Face used to display directories in wfnames buffer.")
+
+(defface wfnames-symlink '((t :foreground "Orange"))
+ "Face used to display symlinks in wfnames buffer.")
+
+(defface wfnames-prefix '((t :foreground "Gold"))
+ "Face used to prefix filenames in wfnames buffer.")
(defvar wfnames-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-x C-s") #'wfnames-commit-buffer)
+ (define-key map (kbd "C-c C-c") #'wfnames-commit-buffer)
(define-key map (kbd "C-c C-k") #'wfnames-revert-changes)
map))
@@ -112,9 +124,17 @@ Special commands:
(with-current-buffer (get-buffer-create wfnames-buffer)
(save-excursion
(cl-loop for file in files
+ for face = (cond ((file-directory-p file) 'wfnames-dir)
+ ((file-symlink-p file) 'wfnames-symlink)
+ (t 'wfnames-files))
do (insert (propertize
- file 'old-name file 'face 'wfnames-files)
+ file 'old-name file 'face face
+ 'line-prefix (propertize
+ "* "
+ 'face 'wfnames-prefix))
"\n")))
+ ;; 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)))
@@ -140,8 +160,19 @@ Special commands:
(unless (string= old new) ; not modified, skip.
(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 delay real rename to next
+ ;; turn. Make it accessible in
+ ;; 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)
(not (assoc new delayed)))
;; Maybe ask.
@@ -164,18 +195,21 @@ Special commands:
(directory-file-name
new))))
(unless (file-directory-p basedir)
(mkdir basedir 'parents))))
- (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))))
+ (if (and ow (wfnames-ask-for-overwrite new))
+ (rename-file
+ ;; Use old temp file if it
+ ;; exists [1].
+ (or (assoc-default old delayed) old)
+ new ow)
+ ;; 'No' answered.
+ (and ow (cl-incf skipped))
+ ;; 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 2, delete it.
+ ;; clause 1, delete it.
(when (and tmp (file-exists-p tmp))
(if (file-directory-p tmp)
(delete-directory tmp t)
@@ -186,7 +220,8 @@ Special commands:
(forward-line 1)))
(when delayed (commit)))))
(commit)
- (message "* Renamed %s file(s), Skipped %s file(s)" renamed skipped)
+ (run-hooks 'wfnames-after-commit-hook)
+ (message "Renamed %s file(s), Skipped %s file(s)" renamed skipped)
(kill-buffer wfnames-buffer))))
(defun wfnames-revert-changes ()
@@ -204,8 +239,12 @@ Special commands:
(unless (string= old new)
(delete-region (point-at-bol) (point-at-eol))
(insert (propertize
- old 'old-name old 'face 'helm-ff-file)))
- (forward-line 1))))))
+ old 'old-name old 'face 'wfnames-file
+ 'line-prefix (propertize
+ "* "
+ 'face 'wfnames-prefix))))
+ (forward-line 1))))
+ (while (re-search-forward "/" (point-at-eol) t))))
(provide 'wfnames)
- [nongnu] elpa/wfnames ccf3696257 12/98: Update TODO, (continued)
- [nongnu] elpa/wfnames ccf3696257 12/98: Update TODO, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 924319f51a 23/98: Fixup comments, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 8e34c7bb75 18/98: Reindent, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 73104c1cbd 29/98: Fix group and use someting else than helm-basedir, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 2e9f34d939 20/98: Handle directories rename, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames d034d09e6d 36/98: Restore props after changes made by something else than self-insert-command, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 810aea61db 38/98: Long lines only, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames ac577774ef 40/98: Revert "Handle backup overwrite", ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames f510d716b6 43/98: Fix interactive rename, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 221ac4691f 52/98: Add face to prefix filenames in wfnames buffer, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 860512b33c 58/98: Merge branch 'devel' into main,
ELPA Syncer <=
- [nongnu] elpa/wfnames 056e032d18 60/98: Save all overwrites in an alist, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames d58dbf06c3 67/98: Add wfnames-make-backup, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 53813526b1 62/98: Bind C-x C-s, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames fefd46c97e 74/98: Fix headers, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 59a61c5725 80/98: Update README, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 7202294447 85/98: Allow appending to existing wfnames-buffer, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 7b50001525 89/98: Shutup warnings with point-at-bol/eol, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 900da88db7 91/98: Use defconst for buffer name and prefer defvar-local, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 9c99e94560 10/98: Fix paren error, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames a0d1f99760 02/98: Fix overwriting, ELPA Syncer, 2023/08/08