[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/disk-usage 8bf5d5c 08/26: Break some long lines
From: |
Pierre Neidhardt |
Subject: |
[elpa] externals/disk-usage 8bf5d5c 08/26: Break some long lines |
Date: |
Tue, 26 Feb 2019 03:06:37 -0500 (EST) |
branch: externals/disk-usage
commit 8bf5d5c4949e87c2fb38bb91d7c55eba25f42286
Author: Pierre Neidhardt <address@hidden>
Commit: Pierre Neidhardt <address@hidden>
Break some long lines
---
disk-usage.el | 124 +++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 74 insertions(+), 50 deletions(-)
diff --git a/disk-usage.el b/disk-usage.el
index 39963fa..2e4aec9 100644
--- a/disk-usage.el
+++ b/disk-usage.el
@@ -77,9 +77,10 @@
(defvar disk-usage--du-args "-sb")
(defvar disk-usage--find-command "find")
-(defcustom disk-usage--directory-size-function (if (executable-find
disk-usage--du-command)
-
#'disk-usage--directory-size-with-du
-
#'disk-usage--directory-size-with-emacs)
+(defcustom disk-usage--directory-size-function
+ (if (executable-find disk-usage--du-command)
+ #'disk-usage--directory-size-with-du
+ #'disk-usage--directory-size-with-emacs)
"Function that returns the total disk usage of the directory passed as
argument."
:type '(choice (function :tag "Native (slow)"
disk-usage--directory-size-with-emacs)
(function :tag "System \"du\""
disk-usage--directory-size-with-du)))
@@ -133,26 +134,31 @@
(setq directory (or directory default-directory))
(let ((listing (or listing
(and (file-accessible-directory-p directory)
- (directory-files-and-attributes directory 'full nil
'nosort)))))
+ (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)
;; Files
if (null (file-attribute-type attributes))
- collect (disk-usage--file-info-make :name path
- :size
(file-attribute-size attributes))
+ collect (disk-usage--file-info-make
+ :name path
+ :size (file-attribute-size attributes))
;; Symlinks
if (stringp (file-attribute-type attributes))
- collect (disk-usage--file-info-make :name path
- :size
(file-attribute-size attributes))
+ collect (disk-usage--file-info-make
+ :name path
+ :size (file-attribute-size attributes))
;; Folders
else if (and (eq t (file-attribute-type attributes))
(not (string= "." (file-name-base path)))
(not (string= ".." (file-name-base path))))
collect
- (disk-usage--file-info-make :name path
- :size (disk-usage--directory-size
path)
- :children (- (length
(directory-files path)) 2)))
+ (disk-usage--file-info-make
+ :name path
+ :size (disk-usage--directory-size path)
+ :children (- (length (directory-files path)) 2)))
(list (disk-usage--file-info-make :size 0 :name directory)))))
(defun disk-usage--list-recursively (directory)
@@ -168,7 +174,9 @@ $ find . -type f -exec du -sb {} +"
(process-file disk-usage--find-command nil '(t nil)
nil
directory
"-type" "f"
- "-exec" disk-usage--du-command
disk-usage--du-args "{}" "+")
+ "-exec"
+ disk-usage--du-command
+ disk-usage--du-args "{}" "+")
(buffer-string))
"\n" 'omit-nulls)))
@@ -256,21 +264,24 @@ Takes a number and returns a string."
(disk-usage--set-tabulated-list-format )
(tabulated-list-init-header)
(setq tabulated-list-entries
- (mapcar (lambda (file-info)
- (list file-info (vector (number-to-string
(disk-usage--file-info-size file-info))
- (format "%.1f%%"
- (* 100 (/ (float
(disk-usage--file-info-size file-info))
- total-size)))
- (number-to-string
(disk-usage--file-info-children file-info))
- (let ((name
(disk-usage--file-info-name file-info)))
- (if (file-directory-p name)
- ;; Make button.
- (cons name
- (list 'action
- (lambda (_)
- (disk-usage
name))))
- name)))))
- listing))))
+ (mapcar
+ (lambda (file-info)
+ (list file-info
+ (vector
+ (number-to-string (disk-usage--file-info-size file-info))
+ (format "%.1f%%"
+ (* 100 (/ (float (disk-usage--file-info-size
file-info))
+ total-size)))
+ (number-to-string (disk-usage--file-info-children
file-info))
+ (let ((name (disk-usage--file-info-name file-info)))
+ (if (file-directory-p name)
+ ;; Make button.
+ (cons name
+ (list 'action
+ (lambda (_)
+ (disk-usage name))))
+ name)))))
+ listing))))
(defvar disk-usage--format-files #'identity
"How to print files.
@@ -335,7 +346,10 @@ FILE-ENTRY may be a string or a button."
(list (or (tabulated-list-get-entry (point-at-bol 0))
cols)
cols))))
- (setq x (tabulated-list-print-col 0 (funcall
disk-usage-size-format-function (string-to-number (aref cols 0))) x))
+ (setq x (tabulated-list-print-col 0
+ (funcall
disk-usage-size-format-function
+ (string-to-number (aref cols
0)))
+ x))
(setq x (tabulated-list-print-col 1 (aref cols 1) x))
(setq x (tabulated-list-print-col 2 (aref cols 2) x))
(setq x (tabulated-list-print-col 3 (disk-usage--print-file-col (aref
cols 3)) x))
@@ -478,18 +492,24 @@ TYPE is the file extension (lower case)."
(let ((listing (disk-usage--list-recursively directory))
(table (make-hash-table :test #'equal)))
(dolist (file-info listing)
- (let* ((ext (downcase (or (file-name-extension
(disk-usage--file-info-name file-info)) "")))
+ (let* ((ext (downcase (or (file-name-extension
+ (disk-usage--file-info-name file-info))
+ "")))
(size (disk-usage--file-info-size file-info))
(type (gethash ext table)))
(puthash ext
(if (not type)
- (disk-usage--type-info-make :names (list
(disk-usage--file-info-name file-info))
- :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-names 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)))
+ (disk-usage--type-info-names type)
+ (cons (disk-usage--file-info-name file-info)
+ (disk-usage--type-info-names type)))
+ (setf (disk-usage--type-info-count type)
+ (1+ (disk-usage--type-info-count type)))
+ (setf (disk-usage--type-info-size type)
+ (+ size (disk-usage--type-info-size type)))
type)
table)))
table))
@@ -516,7 +536,8 @@ TYPE is the file extension (lower case)."
("Count" 12 disk-usage-by-types--sort-by-count)
("%%" 6 disk-usage-by-types--sort-by-size . (:right-align t))
("Total size" 12 disk-usage-by-types--sort-by-size . (:right-align
t))
- ("Average size" 15 disk-usage-by-types--sort-by-average .
(:right-align t))]))
+ ("Average size" 15
+ disk-usage-by-types--sort-by-average . (:right-align t))]))
(defun disk-usage-by-types--refresh (&optional directory)
(setq directory (or directory default-directory))
@@ -527,19 +548,21 @@ TYPE is the file extension (lower case)."
sum (disk-usage--type-info-size e))))
(setq tabulated-list-entries
(cl-loop for e being the hash-values of listing using (hash-keys
ext)
- collect (list e
- (vector
- ext
- (number-to-string
(disk-usage--type-info-count e))
- (format "%.1f%%"
- (* 100 (/ (float
(disk-usage--type-info-size e))
- total-size)))
- (funcall disk-usage-size-format-function
- (disk-usage--type-info-size e))
- (funcall disk-usage-size-format-function
- (string-to-number
- (format "%.2f"
-
(disk-usage--type-average-size e)))))))))))
+ collect
+ (list
+ e
+ (vector
+ ext
+ (number-to-string (disk-usage--type-info-count e))
+ (format "%.1f%%"
+ (* 100 (/ (float (disk-usage--type-info-size e))
+ total-size)))
+ (funcall disk-usage-size-format-function
+ (disk-usage--type-info-size e))
+ (funcall disk-usage-size-format-function
+ (string-to-number
+ (format "%.2f"
+ (disk-usage--type-average-size
e)))))))))))
(defvar disk-usage-by-types-mode-map
(let ((map (make-sparse-keymap)))
@@ -582,7 +605,8 @@ Also see `disk-usage-mode'."
(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))))
+ (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
- [elpa] externals/disk-usage 7fd6e43 19/26: Add filters to recursive listings, (continued)
- [elpa] externals/disk-usage 7fd6e43 19/26: Add filters to recursive listings, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage cec7fc6 02/26: Require Emacs 26 for file-attribute-* functions, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 2874158 03/26: Add TODOs about file-notify, date filtering, formatting and process-file, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage c44cc97 01/26: Set default for directory-size-function dynamically, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 6846590 15/26: Add 1-hour filter, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 1d85ea5 10/26: Fix missing total-size in header, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 0feb208 18/26: Message instead of warning when no filters, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage aa7d267 17/26: Document filters, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage bcae407 21/26: Replace (delq (mapcar ...)) with cl-loop, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 54d4aee 25/26: Propertize size, percent and children columns, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 8bf5d5c 08/26: Break some long lines,
Pierre Neidhardt <=
- [elpa] externals/disk-usage 0fff6a8 12/26: Fix 'nil' children issue on inaccessible directories, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage a53be8d 26/26: Version 1.2.0, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 6a01954 05/26: Rename disk-usage--path-at-point -> disk-usage--file-name-at-point, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 364c62b 20/26: Bind "a" and "A" to filter commands in disk-usage-by-types, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 6a214bc 09/26: Add many docstrings, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 488ddc8 14/26: Add support for filters, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 7708379 07/26: Use process-file instead of call-process, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 7b14829 22/26: Normalize filter names, Pierre Neidhardt, 2019/02/26
- [elpa] externals/disk-usage 2d36a87 04/26: Fix disk-usage--path-at-point to return directory, Pierre Neidhardt, 2019/02/26