[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage 1806ea2 46/48: Support region and numeric ar
From: |
Stefan Monnier |
Subject: |
[elpa] externals/disk-usage 1806ea2 46/48: Support region and numeric arg when marking |
Date: |
Tue, 19 Feb 2019 08:00:06 -0500 (EST) |
branch: externals/disk-usage
commit 1806ea2a7b91e95d69c89d3fed799cc8aa8f3e40
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Support region and numeric arg when marking
---
disk-usage.el | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index a1f9cb3..eb04016 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -99,8 +99,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 "u" #'disk-usage-unmark-at-point)
+ (define-key map "m" #'disk-usage-mark)
+ (define-key map "u" #'disk-usage-unmark)
(define-key map "x" #'disk-usage-delete-marked-files)
map)
"Local keymap for `disk-usage-mode' buffers.")
@@ -389,17 +389,31 @@ Also see `disk-usage-by-types-mode'."
path
(setq path (file-name-directory path)))))
-(defun disk-usage-mark-at-point ()
- (interactive)
- (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-unmark-at-point ()
- (interactive)
- (let ((file-info (tabulated-list-get-id (point))))
- (setf (disk-usage--file-info-marked file-info) nil))
- (tabulated-list-put-tag "" 'advance))
+(defun disk-usage-mark-at-point (&optional count mark)
+ (interactive "p")
+ (let ((step (if (> count 0) 1 -1)))
+ (setq count (abs count)
+ mark (or mark "*"))
+ (dotimes (_ count)
+ (let ((file-info (tabulated-list-get-id (point))))
+ (setf (disk-usage--file-info-marked file-info) (string= mark "")))
+ (tabulated-list-put-tag mark)
+ (forward-line step))))
+
+(defun disk-usage-mark (&optional count mark)
+ (interactive "p")
+ (if (region-active-p)
+ (let ((count (count-lines
+ (region-beginning)
+ (region-end))))
+ (save-mark-and-excursion
+ (goto-char (region-beginning))
+ (disk-usage-mark-at-point count mark)))
+ (disk-usage-mark-at-point count mark)))
+
+(defun disk-usage-unmark (&optional count)
+ (interactive "p")
+ (disk-usage-mark count ""))
(defun disk-usage-delete-marked-files (&optional permanently)
"Delete marked files.
- [elpa] externals/disk-usage 5998d42 41/48: Version 1.0.0, (continued)
- [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, 2019/02/19
- [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 <=
- [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