[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage 01561b5 30/48: Implement marking and deletio
From: |
Stefan Monnier |
Subject: |
[elpa] externals/disk-usage 01561b5 30/48: Implement marking and deletion |
Date: |
Tue, 19 Feb 2019 08:00:02 -0500 (EST) |
branch: externals/disk-usage
commit 01561b5844f08d6d331691adcbefaac520bdc008
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Implement marking and deletion
---
disk-usage.el | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index 116dca0..3ba8e9c 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -89,6 +89,8 @@
(define-key map "h" #'disk-usage-toggle-human-readable)
(define-key map "f" #'disk-usage-toggle-full-path)
(define-key map "R" #'disk-usage-toggle-recursive)
+ (define-key map "m" #'disk-usage-mark-at-point)
+ (define-key map "x" #'disk-usage-delete-marked-files)
map)
"Local keymap for `disk-usage-mode' buffers.")
@@ -98,7 +100,8 @@
(:constructor nil)
(:constructor disk-usage--file-info-make))
size
- name)
+ name
+ (marked nil))
(defun disk-usage-reset-cache ()
(interactive)
@@ -320,6 +323,7 @@ beings."
(define-derived-mode disk-usage-mode tabulated-list-mode "Disk Usage"
"Mode to display disk usage."
;; TODO: Option to display extra attributes and default column to sort.
+ (setq tabulated-list-padding 2)
(setq tabulated-list-sort-key (cons "Size" 'flip))
(setq tabulated-list-printer #'disk-usage--print-entry)
(add-hook 'tabulated-list-revert-hook 'disk-usage--refresh nil t))
@@ -369,11 +373,23 @@ beings."
path
(setq path (file-name-directory path)))))
-;; TODO: Mark files?
-(defun disk-usage-delete-at-point ()
+(defun disk-usage-mark-at-point ()
(interactive)
- (delete-file (disk-usage--path-at-point))
- (tabulated-list-delete-entry))
+ (let ((file-info (tabulated-list-get-id (point))))
+ (setf (disk-usage--file-info-marked file-info) t))
+ (tabulated-list-put-tag "*" 'advance))
+
+(defun disk-usage-delete-marked-files (&optional permanently)
+ "Delete marked files.
+By default, files are moved to trash unless PERMANENTLY is
+non-nil or with prefix argument."
+ (interactive "P")
+ (when (yes-or-no-p "Delete marked files?")
+ (cl-loop for entry in tabulated-list-entries
+ if (disk-usage--file-info-marked (car entry))
+ do (let ((delete-by-moving-to-trash (not permanently)))
+ (delete-file (disk-usage--file-info-name (car entry))))))
+ (tabulated-list-revert))
(defun disk-usage-find-file-at-point ()
(interactive)
- [elpa] externals/disk-usage d959b7b 36/48: Display % column and sort types by total size, (continued)
- [elpa] externals/disk-usage d959b7b 36/48: Display % column and sort types by total size, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 3bbb09a 44/48: Right-align columns with units, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 441abf9 20/48: Add disk-usage-by-types, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 2d6fe3c 08/48: Resolve directory statically in button action, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 5998d42 41/48: Version 1.0.0, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 21b5749 38/48: Add disk-usage-files, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage e44979a 45/48: Version 1.1.0, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 696dd5c2 17/48: Fix free references, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage c55d478 34/48: Document modes and prefix argument, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 3af5aa8 25/48: Reset hash table properly, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 01561b5 30/48: Implement marking and deletion,
Stefan Monnier <=
- [elpa] externals/disk-usage ae7ba9c 39/48: Fix missing "s" in type-info-names, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage d8d1643 35/48: Document file deletion, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 342d381 18/48: Add recursive listings, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 1806ea2 46/48: Support region and numeric arg when marking, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage f3c64a1 43/48: Prompt whether deleting or trashing and only revert if proceeding, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 7e0705e 47/48: Display percentage in disk-usage, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 745dd7e 01/48: Init, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage f89b69d 48/48: Display children in disk-usage, Stefan Monnier, 2019/02/19