[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/wfnames ee195dbf42 26/98: Fix name prefixes
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/wfnames ee195dbf42 26/98: Fix name prefixes |
Date: |
Tue, 8 Aug 2023 04:01:14 -0400 (EDT) |
branch: elpa/wfnames
commit ee195dbf42c7d9dbae06eae8a88c46047bb0df9b
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Fix name prefixes
Add a function to be used with something else than helm
---
helm-edit-marked.el | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/helm-edit-marked.el b/helm-edit-marked.el
index a24f3a4cfc..e42fab9435 100644
--- a/helm-edit-marked.el
+++ b/helm-edit-marked.el
@@ -8,17 +8,17 @@
(defvar helm-ff-edit-buffer "*Edit hff marked*")
(defvar helm-ff--edit-marked-old-files nil)
-(defvar helm-ff-edit-marked-create-parent-directories nil)
-(defvar helm-ff-edit-marked-interactive-rename nil)
+(defvar helm-edit-marked-create-parent-directories nil)
+(defvar helm-edit-marked-interactive-rename nil)
;; TODO:
;; - Handle backing up when overwriting
-;; (defvar helm-ff-edit-marked-make-backup nil)
+;; (defvar helm-edit-marked-make-backup nil)
(defvar helm-ff-edit-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-x C-s") #'helm-ff-edit-marked-commit-buffer)
- (define-key map (kbd "C-c C-k") #'helm-ff-edit-marked-revert-changes)
+ (define-key map (kbd "C-x C-s") #'helm-edit-marked-commit-buffer)
+ (define-key map (kbd "C-c C-k") #'helm-edit-marked-revert-changes)
map))
(define-derived-mode helm-ff-edit-mode text-mode
@@ -28,9 +28,9 @@
Special commands:
\\{helm-ff-edit-mode-map}
"
- (add-hook 'after-change-functions #'helm-ff-edit-marked-after-change-hook
nil t))
+ (add-hook 'after-change-functions #'helm-edit-marked-after-change-hook nil
t))
-(defun helm-ff-edit-marked-after-change-hook (beg _end _leng-before)
+(defun helm-edit-marked-after-change-hook (beg _end _leng-before)
(with-current-buffer helm-ff-edit-buffer
(save-excursion
(save-match-data
@@ -58,19 +58,23 @@ Special commands:
(overlay-put ov 'priority 0)
(overlay-put ov 'evaporate t))))))))
+(defun helm-edit-marked-setup-buffer (files)
+ (with-current-buffer (get-buffer-create helm-ff-edit-buffer)
+ (save-excursion
+ (cl-loop for file in files
+ do (insert (propertize
+ file 'old-name file 'face 'helm-ff-file)
+ "\n")))
+ (helm-ff-edit-mode)
+ (set (make-local-variable 'helm-ff--edit-marked-old-files) files)))
+
+;; This is the action for HFF.
(defun helm-ff-edit-marked-files (_candidate)
(let ((marked (helm-marked-candidates)))
- (with-current-buffer (get-buffer-create helm-ff-edit-buffer)
- (save-excursion
- (cl-loop for file in marked
- do (insert (propertize
- file 'old-name file 'face 'helm-ff-file)
- "\n")))
- (helm-ff-edit-mode)
- (set (make-local-variable 'helm-ff--edit-marked-old-files) marked))
+ (helm-edit-marked-setup-buffer marked)
(switch-to-buffer helm-ff-edit-buffer)))
-(defun helm-ff-edit-marked-commit-buffer ()
+(defun helm-edit-marked-commit-buffer ()
(interactive)
(let ((renamed 0) (skipped 0) delayed)
(cl-labels ((commit ()
@@ -92,7 +96,7 @@ Special commands:
helm-ff--edit-marked-old-files)
(not (assoc new delayed)))
;; Maybe ask
- (if (or (null
helm-ff-edit-marked-interactive-rename)
+ (if (or (null
helm-edit-marked-interactive-rename)
(y-or-n-p (format "File `%s' exists,
overwrite? "
new)))
(let ((tmpfile (make-temp-name old)))
@@ -111,7 +115,7 @@ Special commands:
(and (file-exists-p new)
(not (assoc new delayed)))
;; Maybe ask.
- (if (or (null
helm-ff-edit-marked-interactive-rename)
+ (if (or (null
helm-edit-marked-interactive-rename)
(y-or-n-p (format "File `%s' exists,
overwrite? "
new)))
(let ((tmpfile (make-temp-name new)))
@@ -122,7 +126,7 @@ Special commands:
beg end `(old-name ,new))
(cl-incf skipped)))
(t ; Now really rename files.
- (when
helm-ff-edit-marked-create-parent-directories
+ (when
helm-edit-marked-create-parent-directories
;; Check if base directory of new exists.
(let ((basedir (helm-basedir new 'parent)))
(unless (file-directory-p basedir)
@@ -149,7 +153,7 @@ Special commands:
(message "* Renamed %s file(s), Skipped %s file(s)" renamed skipped)
(kill-buffer helm-ff-edit-buffer))))
-(defun helm-ff-edit-marked-revert-changes ()
+(defun helm-edit-marked-revert-changes ()
(interactive)
(with-current-buffer helm-ff-edit-buffer
(cl-loop for o in (overlays-in (point-min) (point-max))
- [nongnu] elpa/wfnames 8028da5298 32/98: Fix headers, (continued)
- [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, 2023/08/08
- [nongnu] elpa/wfnames ee195dbf42 26/98: Fix name prefixes,
ELPA Syncer <=
- [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
- [nongnu] elpa/wfnames db1f17a5dd 92/98: Require emacs-24.4 for delete-duplicate-lines, ELPA Syncer, 2023/08/08