[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage 9b55d63 09/48: Add disk-usage-toggle-full-pa
From: |
Stefan Monnier |
Subject: |
[elpa] externals/disk-usage 9b55d63 09/48: Add disk-usage-toggle-full-path |
Date: |
Tue, 19 Feb 2019 07:59:58 -0500 (EST) |
branch: externals/disk-usage
commit 9b55d63aeb9e9023db470de9d496533104a41f2a
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Add disk-usage-toggle-full-path
---
disk-usage.el | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index f801a7e..525a129 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -147,7 +147,7 @@ This is slow but does not require any external process."
(defun disk-usage--set-format (total-size)
(setq tabulated-list-format
`[("Size"
- ,(if (eq disk-usage--format #'file-size-human-readable)
+ ,(if (eq disk-usage--format-size #'file-size-human-readable)
8
12)
,disk-usage--sort . (:right-align t))
@@ -181,18 +181,41 @@ This is slow but does not require any external process."
;; TODO: Customize sort options.
(defvar disk-usage--sort #'disk-usage--sort-size-<)
-(defvar disk-usage--format #'file-size-human-readable
+(defvar disk-usage--format-size #'file-size-human-readable
"How to print size.
Takes a number and returns a string.
`file-size-human-readable' and `number-to-string' are good candidates.")
+(defvar disk-usage--format-files #'identity
+ "How to print files.
+Takes a string and returns a string.
+`identity' and `file-name-nondirectory' are good candidates.")
+
(defun disk-usage-toggle-human-readable ()
(interactive)
- (if (eq disk-usage--format #'file-size-human-readable)
- (setq disk-usage--format #'number-to-string)
- (setq disk-usage--format #'file-size-human-readable))
+ (setq disk-usage--format-size
+ (if (eq disk-usage--format-size #'file-size-human-readable)
+ #'number-to-string
+ #'file-size-human-readable))
(tabulated-list-revert))
+(defun disk-usage-toggle-full-path ()
+ (interactive)
+ (setq disk-usage--format-files
+ (if (eq disk-usage--format-files #'identity)
+ #'file-name-nondirectory
+ #'identity))
+ (tabulated-list-revert))
+
+(defun disk-usage--print-file-col (file-entry)
+ "Call `disk-usage--format-file' on FILE-ENTRY.
+FILE-ENTRY may be a string or a button."
+ (if (listp file-entry)
+ (let ((copy (cl-copy-list file-entry)))
+ (setcar copy (funcall disk-usage--format-files (car copy)))
+ copy)
+ (funcall disk-usage--format-files file-entry)))
+
(defun disk-usage--print-entry (id cols)
"Like `tabulated-list-print-entry' but formats size for human
beings."
@@ -207,8 +230,9 @@ beings."
(list (or (tabulated-list-get-entry (point-at-bol 0))
cols)
cols))))
- (setq x (tabulated-list-print-col 0 (funcall disk-usage--format
(string-to-number (aref cols 0))) x))
- (cl-loop for i from 1 below ncols
+ (setq x (tabulated-list-print-col 0 (funcall disk-usage--format-size
(string-to-number (aref cols 0))) x))
+ (setq x (tabulated-list-print-col 1 (disk-usage--print-file-col (aref
cols 1)) x))
+ (cl-loop for i from 2 below ncols
do (setq x (tabulated-list-print-col i (aref cols i) x))))
(insert ?\n)
;; Ever so slightly faster than calling `put-text-property' twice.
- [elpa] branch externals/disk-usage created (now f89b69d), Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage e6f342a 04/48: Bind "h" to toggle-human-readable, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 28ceb1a 02/48: Alight size to the right, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 4ce2b9b 03/48: Update buffer when toggling human readable size, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 0123f06 06/48: Display symlink targets, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 8792145 16/48: Bind "f" to disk-usage-toggle-full-path, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 3fb4803 07/48: Display total size, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage b2497fd 19/48: Set buffer name in a defvar, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage ca3aa43 05/48: Display symlinks, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage f35eb8b 26/48: Refactor disk-usage-toggle-recursive, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 9b55d63 09/48: Add disk-usage-toggle-full-path,
Stefan Monnier <=
- [elpa] externals/disk-usage f3bcae9 22/48: readme: Link to Guix, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage f330f01 31/48: Fix structure manipulation in disk-usage-by-types, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 00aa40a 10/48: Bind "S-<return>" to disk-usage-find-file-at-point, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 4fc5cb3 33/48: Refresh cache with prefix argument, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 1949c82 37/48: Add disk-usage-by-types-here, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage f3895a3 27/48: Normalize some function names, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 0d4ce4b 12/48: Bind "^" and "<backspace>" to disk-usage-up, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage aa3996e 24/48: Default to disk-usage--list, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage 90607dc 23/48: Use file-info structure instead of vectors, Stefan Monnier, 2019/02/19
- [elpa] externals/disk-usage ed9dc23 11/48: Keep cursor on current entry when re-ordering buffer, Stefan Monnier, 2019/02/19