emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fd54102: * lisp/files.el (file-size-function): New


From: Oleh Krehel
Subject: [Emacs-diffs] master fd54102: * lisp/files.el (file-size-function): New defcustom
Date: Fri, 19 Jul 2019 12:57:11 -0400 (EDT)

branch: master
commit fd5410217ff23810edc16e97c10934ad622f8e4b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    * lisp/files.el (file-size-function): New defcustom
---
 etc/NEWS      |  1 +
 lisp/files.el | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index c875fc6..5cbe60c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -400,6 +400,7 @@ mode they are described in the manual "(emacs) Display".
 ---
 ** New variable 'xref-file-name-display' controls the display of file
 names in xref buffers.
+** New variable `file-size-function' controls how file sizes are displayed
 
 
 * Editing Changes in Emacs 27.1
diff --git a/lisp/files.el b/lisp/files.el
index 238aa37..e26b482 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6696,13 +6696,21 @@ This variable is obsolete; Emacs no longer uses it."
                        "ignored, as Emacs uses `file-system-info' instead"
                        "27.1")
 
+(defcustom file-size-function #'file-size-human-readable
+  "Function that transforms the number of bytes into a human-readable string."
+  :type '(choice
+          (const :tag "default" file-size-human-readable)
+          (const :tag "iec"
+           (lambda (size) (file-size-human-readable size 'iec " ")))
+          (function :tag "Custom function")))
+
 (defun get-free-disk-space (dir)
   "String describing the amount of free space on DIR's file system.
 If DIR's free space cannot be obtained, this function returns nil."
   (save-match-data
     (let ((avail (nth 2 (file-system-info dir))))
       (if avail
-          (file-size-human-readable avail 'iec " ")))))
+          (funcall file-size-function avail)))))
 
 ;; The following expression replaces `dired-move-to-filename-regexp'.
 (defvar directory-listing-before-filename-regexp



reply via email to

[Prev in Thread] Current Thread [Next in Thread]