From fd5410217ff23810edc16e97c10934ad622f8e4b Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Fri, 19 Jul 2019 18:55:29 +0200 Subject: [PATCH] * 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 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 -- 2.39.2