ibuffer: New defcustom `ibuffer-human-readable-size'

* lisp/ibuffer.el (ibuffer-human-readable-size): New
defcustom.
(define-ibuffer-column size): Use it.

* etc/NEWS: Mention new defcustom.
(Bug#75495)
This commit is contained in:
Daniel Mendler 2025-01-11 14:22:02 +01:00 committed by Eli Zaretskii
parent 5e0fc49f3b
commit 35576fde56
2 changed files with 23 additions and 9 deletions

View file

@ -354,6 +354,9 @@ You can now set `asm-comment-char' from 'asm-mode-hook' instead.
The variable 'ibuffer-formats' configures the Ibuffer formats. Add
'recency' to the format to display the column.
*** New user option 'ibuffer-human-readable-size'.
When non-nil, buffer sizes are shown in human readable format.
** Smerge
*** New command 'smerge-extend' extends a conflict over surrounding lines.

View file

@ -186,6 +186,12 @@ recreate it for the change to take effect."
(sexp :tag "Test Form")
face)))
(defcustom ibuffer-human-readable-size nil
"Show buffer sizes in human-readable format.
Use the function `file-size-human-readable' for formatting."
:type 'boolean
:version "31.1")
(defcustom ibuffer-use-other-window nil
"If non-nil, display Ibuffer in another window by default."
:type 'boolean)
@ -1714,15 +1720,20 @@ If point is on a group name, this function operates on that group."
(:inline t
:header-mouse-map ibuffer-size-header-map
:summarizer
(lambda (column-strings)
(let ((total 0))
(dolist (string column-strings)
(setq total
;; like, ewww ...
(+ (float (string-to-number string))
total)))
(format "%.0f" total))))
(format "%s" (buffer-size)))
(lambda (strings)
(let ((total
(cl-loop
for s in strings
for i = (text-property-not-all 0 (length s) 'ibuffer-size nil s)
if i sum (get-text-property i 'ibuffer-size s))))
(if ibuffer-human-readable-size
(file-size-human-readable total)
(number-to-string total)))))
(let ((size (buffer-size)))
(propertize (if ibuffer-human-readable-size
(file-size-human-readable size)
(number-to-string size))
'ibuffer-size size)))
(define-ibuffer-column recency
(:inline t :summarizer ignore :header-mouse-map ibuffer-recency-header-map)