[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/wfnames ea13dc903e 30/98: Remove helm-edit-marked in favor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/wfnames ea13dc903e 30/98: Remove helm-edit-marked in favor of wfnames |
Date: |
Tue, 8 Aug 2023 04:01:14 -0400 (EDT) |
branch: elpa/wfnames
commit ea13dc903e582e6ba9e245862cb166859ccca616
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Remove helm-edit-marked in favor of wfnames
---
helm-edit-marked.el | 176 ----------------------------------------------------
1 file changed, 176 deletions(-)
diff --git a/helm-edit-marked.el b/helm-edit-marked.el
deleted file mode 100644
index e42fab9435..0000000000
--- a/helm-edit-marked.el
+++ /dev/null
@@ -1,176 +0,0 @@
-;;; helm-edit-marked.el -- Edit marked files. -*- lexical-binding:t -*-
-;;
-
-;;; Code:
-
-(require 'helm)
-
-(defvar helm-ff-edit-buffer "*Edit hff marked*")
-(defvar helm-ff--edit-marked-old-files nil)
-
-(defvar helm-edit-marked-create-parent-directories nil)
-(defvar helm-edit-marked-interactive-rename nil)
-
-;; TODO:
-;; - Handle backing up when overwriting
-;; (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-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
- "helm-ff-edit-mode"
- "Edit HFF marked files.
-
-Special commands:
-\\{helm-ff-edit-mode-map}
-"
- (add-hook 'after-change-functions #'helm-edit-marked-after-change-hook nil
t))
-
-(defun helm-edit-marked-after-change-hook (beg _end _leng-before)
- (with-current-buffer helm-ff-edit-buffer
- (save-excursion
- (save-match-data
- (goto-char beg)
- (let* ((bol (point-at-bol))
- (eol (point-at-eol))
- (old (get-text-property bol 'old-name))
- (new (buffer-substring-no-properties bol eol))
- ov face)
- (setq face `(:background ,(if (file-exists-p new)
- "DarkOrange" "LightBlue")))
- (cl-loop for o in (overlays-in bol eol)
- when (overlay-get o 'hff-changed)
- return (setq ov o))
- (cond ((string= old new)
- (cl-loop for o in (overlays-in bol eol)
- when (overlay-get o 'hff-changed)
- do (delete-overlay o)))
- (ov
- (move-overlay ov bol eol)
- (overlay-put ov 'face face))
- (t (setq ov (make-overlay bol eol))
- (overlay-put ov 'face face)
- (overlay-put ov 'hff-changed t)
- (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)))
- (helm-edit-marked-setup-buffer marked)
- (switch-to-buffer helm-ff-edit-buffer)))
-
-(defun helm-edit-marked-commit-buffer ()
- (interactive)
- (let ((renamed 0) (skipped 0) delayed)
- (cl-labels ((commit ()
- (with-current-buffer helm-ff-edit-buffer
- (goto-char (point-min))
- (while (not (eobp))
- (let* ((beg (point-at-bol))
- (end (point-at-eol))
- (old (get-text-property (point) 'old-name))
- (new (buffer-substring-no-properties beg end)))
- (unless (string= old new) ; not modified, skip.
- (cond (;; New file exists and is one of the
- ;; next files to rename, make a temp
- ;; file of OLD and assign this temp
- ;; file to OLD, then delay renaming
- ;; to next turn.
- (and (file-exists-p new)
- (member new
- helm-ff--edit-marked-old-files)
- (not (assoc new delayed)))
- ;; Maybe ask
- (if (or (null
helm-edit-marked-interactive-rename)
- (y-or-n-p (format "File `%s' exists,
overwrite? "
- new)))
- (let ((tmpfile (make-temp-name old)))
- (push (cons new tmpfile) delayed)
- (rename-file old tmpfile)
- (add-text-properties
- beg end `(old-name ,tmpfile)))
- ;; Answer is no, skip.
- (add-text-properties
- beg end `(old-name ,new))
- (cl-incf skipped)))
- (;; New file exists but is not part of
- ;; the next files to rename, make a
- ;; temp file of NEW and delay renaming
- ;; to next turn.
- (and (file-exists-p new)
- (not (assoc new delayed)))
- ;; Maybe ask.
- (if (or (null
helm-edit-marked-interactive-rename)
- (y-or-n-p (format "File `%s' exists,
overwrite? "
- new)))
- (let ((tmpfile (make-temp-name new)))
- (push (cons new tmpfile) delayed)
- (rename-file new tmpfile))
- ;; Answer is no, skip.
- (add-text-properties
- beg end `(old-name ,new))
- (cl-incf skipped)))
- (t ; Now really rename files.
- (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)
- (mkdir basedir 'parents))))
- (rename-file
- old (if (file-directory-p new)
- (file-name-as-directory new)
- 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.
- (when (and tmp (file-exists-p tmp))
- (if (file-directory-p tmp)
- (delete-directory tmp t)
- (delete-file tmp)))
- (setq delayed
- (delete assoc delayed)))
- (cl-incf renamed))))
- (forward-line 1)))
- (when delayed (commit)))))
- (commit)
- (message "* Renamed %s file(s), Skipped %s file(s)" renamed skipped)
- (kill-buffer helm-ff-edit-buffer))))
-
-(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))
- when (overlay-get o 'hff-changed)
- do (delete-overlay o))
- (goto-char (point-min))
- (save-excursion
- (while (not (eobp))
- (let ((old (get-text-property (point) 'old-name))
- (new (buffer-substring-no-properties
- (point-at-bol) (point-at-eol))))
- (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))))))
-
-(provide 'helm-edit-marked)
-
-;;; helm-edit-marked.el ends here
- [nongnu] elpa/wfnames 2691695d28 53/98: Fix keymap typo, (continued)
- [nongnu] elpa/wfnames 2691695d28 53/98: Fix keymap typo, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames b6b416ef76 55/98: Comment only, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 10b2c1b02b 54/98: Add a hook to run after commit, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 7fcb787f62 73/98: Add missing docstrings, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 6a83cedcda 76/98: Update README, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 17ef480cb6 78/98: Update README, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 8b5f71d68e 81/98: Fix email address, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames 0804263fa2 84/98: Fix both README and Commentary, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames bf0a11c3bf 90/98: Use eval-when-compile to require cl-lib (cl-loop only), ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames e4d6097892 98/98: Use parents arg for make-directory, ELPA Syncer, 2023/08/08
- [nongnu] elpa/wfnames ea13dc903e 30/98: Remove helm-edit-marked in favor of wfnames,
ELPA Syncer <=
- [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