From: Oleh Krehel Date: Fri, 19 Jul 2019 16:55:29 +0000 (+0200) Subject: * lisp/files.el (file-size-function): New defcustom X-Git-Tag: emacs-27.0.90~1854 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd5410217ff23810edc16e97c10934ad622f8e4b;p=emacs.git * lisp/files.el (file-size-function): New defcustom --- diff --git a/etc/NEWS b/etc/NEWS index c875fc693c8..5cbe60c6d8a 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 238aa377985..e26b4820f5e 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