[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage ca3aa43 05/48: Display symlinks
From: |
Stefan Monnier |
Subject: |
[elpa] externals/disk-usage ca3aa43 05/48: Display symlinks |
Date: |
Tue, 19 Feb 2019 07:59:57 -0500 (EST) |
branch: externals/disk-usage
commit ca3aa438b8442bf2ba3fd78952f4837501092187
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Display symlinks
---
disk-usage.el | 42 ++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index 6864dd9..34e8b63 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -38,9 +38,10 @@
(require 'tabulated-list)
(require 'cl-macs)
-;; TODO: Canonical paths
+;; TODO: Print total size.
+;; TODO: Toggle display of full paths. Make sur Helm-FF still works.
;; TODO: Graph support.
-;; TODO: Print symlinks?
+;; TODO: Include screenshots.
;; TODO: When going up, place cursor on right directory.
(defgroup disk-usage nil
@@ -58,6 +59,17 @@
:type '(choice (function :tag "Native (slow)"
disk-usage--directory-size-with-emacs)
(function :tag "System \"du\""
disk-usage--directory-size-with-du)))
+(defface disk-usage-symlink
+ '((t :foreground "orange"))
+ "Face for symlinks."
+ :group 'disk-usage)
+
+(defface disk-usage-symlink-directory
+ '((t :inherit disk-usage-symlink
+ :underline t))
+ "Face for symlinks."
+ :group 'disk-usage)
+
(defvar disk-usage-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map tabulated-list-mode-map)
@@ -82,6 +94,12 @@
for path = (cl-first l)
if (null (file-attribute-type attributes))
collect (vector (file-attribute-size attributes) path)
+ if (stringp (file-attribute-type attributes))
+ collect (vector (file-attribute-size attributes)
+ (propertize path
+ 'face (if (file-directory-p path)
+
'disk-usage-symlink-directory
+ 'disk-usage-symlink)))
else if (and (eq t (file-attribute-type attributes))
(not (string= "." (file-name-base path)))
(not (string= ".." (file-name-base path))))
@@ -152,6 +170,7 @@ Takes a number and returns a string.
(if (eq disk-usage--format #'file-size-human-readable)
(setq disk-usage--format #'number-to-string)
(setq disk-usage--format #'file-size-human-readable))
+ (disk-usage--set-format)
(tabulated-list-revert))
(defun disk-usage--print-entry (id cols)
@@ -183,12 +202,19 @@ beings."
;; guesses the right file.
help-echo ,(aref cols 1)))))
+(defun disk-usage--set-format ()
+ (setq tabulated-list-format
+ `[("Size"
+ ,(if (eq disk-usage--format #'file-size-human-readable)
+ 8
+ 12)
+ ,disk-usage--sort . (:right-align t))
+ (,(format "Files in '%s'" default-directory) 0 t)]))
+
(define-derived-mode disk-usage-mode tabulated-list-mode "Disk Usage"
"Mode to display disk usage."
;; TODO: Option to display extra attributes.
- (setq tabulated-list-format
- `[("Size" 12 ,disk-usage--sort . (:right-align t))
- ("File" 0 t)])
+ (disk-usage--set-format)
(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)
@@ -199,9 +225,9 @@ beings."
(interactive "D")
(unless disk-usage--cache
(setq disk-usage--cache (make-hash-table :test #'equal)))
- (setq directory (or (and (file-directory-p directory)
- directory)
- default-directory))
+ (setq directory (file-truename (or (and (file-directory-p directory)
+ directory)
+ default-directory)))
(switch-to-buffer
(get-buffer-create (format "*disk-usage<%s>*" (directory-file-name
directory))))
(disk-usage-mode)
- [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 <=
- [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, 2019/02/19
- [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