[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage 21b5749 38/48: Add disk-usage-files
From: |
Stefan Monnier |
Subject: |
[elpa] externals/disk-usage 21b5749 38/48: Add disk-usage-files |
Date: |
Tue, 19 Feb 2019 08:00:04 -0500 (EST) |
branch: externals/disk-usage
commit 21b57490f48441275cb642702f2309b41dd8baee
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Add disk-usage-files
---
disk-usage.el | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index 93091ef..c352b99 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -117,10 +117,11 @@
(interactive)
(clrhash disk-usage--cache))
-(defun disk-usage--list (directory)
+(defun disk-usage--list (directory &optional listing)
(setq directory (or directory default-directory))
- (let ((listing (and (file-accessible-directory-p directory)
- (directory-files-and-attributes directory 'full nil
'nosort))))
+ (let ((listing (or listing
+ (and (file-accessible-directory-p directory)
+ (directory-files-and-attributes directory 'full nil
'nosort)))))
(or (cl-loop for l in listing
for attributes = (cl-rest l)
for path = (cl-first l)
@@ -427,7 +428,7 @@ non-nil or with prefix argument."
(cl-defstruct (disk-usage--type-info
(:constructor nil)
(:constructor disk-usage--type-info-make))
- extension
+ names
size
(count 1))
@@ -443,9 +444,11 @@ TYPE is the file extension (lower case)."
(type (gethash ext table)))
(puthash ext
(if (not type)
- (disk-usage--type-info-make :extension ext
- :size size)
+ (disk-usage--type-info-make :names (list
(disk-usage--file-info-name file-info))
+ :size size)
(setf
+ (disk-usage--type-info-names type) (cons
(disk-usage--file-info-name file-info)
+
(disk-usage--type-info-name type))
(disk-usage--type-info-count type) (1+
(disk-usage--type-info-count type))
(disk-usage--type-info-size type) (+ size
(disk-usage--type-info-size type)))
type)
@@ -484,10 +487,10 @@ TYPE is the file extension (lower case)."
(let ((total-size (cl-loop for e being the hash-values of listing
sum (disk-usage--type-info-size e))))
(setq tabulated-list-entries
- (cl-loop for e being the hash-values of listing
+ (cl-loop for e being the hash-values of listing using (hash-keys
ext)
collect (list e
(vector
- (disk-usage--type-info-extension e)
+ ext
(number-to-string
(disk-usage--type-info-count e))
(format "%.1f%%"
(* 100 (/ (float
(disk-usage--type-info-size e))
@@ -509,6 +512,7 @@ Also see `disk-usage-mode'."
(let ((map (make-sparse-keymap)))
(set-keymap-parent map tabulated-list-mode-map)
(define-key map "h" #'disk-usage-toggle-human-readable)
+ (define-key map (kbd "<return>") #'disk-usage-files)
map)
"Local keymap for `disk-usage-by-types-mode' buffers.")
@@ -532,5 +536,21 @@ Also see `disk-usage-mode'."
(interactive)
(disk-usage-by-types default-directory))
+(defvar disk-usage-files-buffer-name "disk-usage-files")
+
+(defun disk-usage-files (&optional listing)
+ (interactive)
+ (unless (eq major-mode 'disk-usage-by-types-mode)
+ (error "Must be in a disk-usage-by-types buffer"))
+ (setq listing (or listing (disk-usage--type-info-names
(tabulated-list-get-id))))
+ (let ((listing-with-attributes (cl-loop for l in listing
+ collect (cons l (file-attributes
l)))))
+ (switch-to-buffer
+ (get-buffer-create (format "*%s*" disk-usage-files-buffer-name)))
+ (disk-usage-mode)
+ (set (make-local-variable 'disk-usage-list-function)
+ (lambda (_) (disk-usage--list nil listing-with-attributes)))
+ (tabulated-list-revert)))
+
(provide 'disk-usage)
;;; disk-usage.el ends here
- [elpa] externals/disk-usage 2626642 15/48: Remove spurious "evil" keyword, (continued)
- [elpa] externals/disk-usage 2626642 15/48: Remove spurious "evil" keyword, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage eefa57f 28/48: Turn disk-usage-size-format-function into a defcustom, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage af22dd4 13/48: Display symlinks when not displaying full paths, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 3ffaf8e 14/48: Fix header display, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 7fe5f1b 40/48: Fix keymap setup in disk-usage-by-types-mode, Stefan Monnier, 2019/02/19
- [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 <=
- [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, 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