GNU bug report logs -
#75825
[PATCH] New user option 'Buffer-menu-human-readable-size'
Previous Next
To reply to this bug, email your comments to 75825 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75825
; Package
emacs
.
(Sat, 25 Jan 2025 11:46:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Pengji Zhang <me <at> pengjiz.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 25 Jan 2025 11:46:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
This patch introduces a new user option similar to the one in bug#75495.
With it we could display buffer sizes in the human readable format for
Buffer Menu.
Thanks!
Pengji
[0001-New-user-option-Buffer-menu-human-readable-size.patch (text/x-patch, inline)]
From 423df97d414ea6443e0c74c0978ab9a4faeb9476 Mon Sep 17 00:00:00 2001
From: Pengji Zhang <me <at> pengjiz.com>
Date: Sat, 25 Jan 2025 19:29:26 +0800
Subject: [PATCH] New user option 'Buffer-menu-human-readable-size'
* lisp/buff-menu.el (Buffer-menu-human-readable-size): New user
option.
(list-buffers--refresh): Use it.
* etc/NEWS: Annouce the new user option.
---
etc/NEWS | 5 +++++
lisp/buff-menu.el | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 385e943c997..612d1fd88f3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -361,6 +361,11 @@ set to 'title'.
*** New user option 'ibuffer-human-readable-size'.
When non-nil, buffer sizes are shown in human readable format.
+---
+** Buffer Menu
+*** New user option 'Buffer-menu-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.
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 4418db01724..7790475f1f6 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -135,6 +135,14 @@ Buffer-menu-group-sort-by
:group 'Buffer-menu
:version "30.1")
+(defcustom Buffer-menu-human-readable-size nil
+ "If non-nil, show buffer sizes in human-readable format.
+That means to use `file-size-human-readable' (which see) to format the
+buffer sizes in the buffer size column."
+ :type 'boolean
+ :group 'Buffer-menu
+ :version "31.1")
+
(defvar-local Buffer-menu-files-only nil
"Non-nil if the current Buffer Menu lists only file buffers.
This is set by the prefix argument to `buffer-menu' and related
@@ -831,7 +839,10 @@ list-buffers--refresh
(if buffer-read-only "%" " ")
(if (buffer-modified-p) "*" " ")
(Buffer-menu--pretty-name name)
- (number-to-string (buffer-size))
+ (funcall (if Buffer-menu-human-readable-size
+ #'file-size-human-readable
+ #'number-to-string)
+ (buffer-size))
(concat (format-mode-line mode-name
nil nil buffer)
(if mode-line-process
--
2.48.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75825
; Package
emacs
.
(Sun, 26 Jan 2025 11:25:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 75825 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Sat, 25 Jan 2025 19:45:29 +0800, Pengji Zhang <me <at> pengjiz.com> said:
Pengji> Hello,
Pengji> This patch introduces a new user option similar to the one in bug#75495.
Pengji> With it we could display buffer sizes in the human readable format for
Pengji> Buffer Menu.
As with #75495, "size" or "sizes", please pick one and only one.
Pengji> Thanks!
Pengji> Pengji
Pengji> From 423df97d414ea6443e0c74c0978ab9a4faeb9476 Mon Sep 17 00:00:00 2001
Pengji> From: Pengji Zhang <me <at> pengjiz.com>
Pengji> Date: Sat, 25 Jan 2025 19:29:26 +0800
Pengji> Subject: [PATCH] New user option 'Buffer-menu-human-readable-size'
Pengji> * lisp/buff-menu.el (Buffer-menu-human-readable-size): New user
Pengji> option.
Pengji> (list-buffers--refresh): Use it.
Pengji> * etc/NEWS: Annouce the new user option.
Pengji> ---
Pengji> etc/NEWS | 5 +++++
Pengji> lisp/buff-menu.el | 13 ++++++++++++-
Pengji> 2 files changed, 17 insertions(+), 1 deletion(-)
Pengji> diff --git a/etc/NEWS b/etc/NEWS
Pengji> index 385e943c997..612d1fd88f3 100644
Pengji> --- a/etc/NEWS
Pengji> +++ b/etc/NEWS
Pengji> @@ -361,6 +361,11 @@ set to 'title'.
Pengji> *** New user option 'ibuffer-human-readable-size'.
Pengji> When non-nil, buffer sizes are shown in human readable format.
Pengji> +---
Pengji> +** Buffer Menu
Pengji> +*** New user option 'Buffer-menu-human-readable-size'.
Pengji> +When non-nil, buffer sizes are shown in human readable format.
Pengji> +
When adding a new user option, please describe the default value. I
assume itʼs nil, but NEWS should tell me (especially as NEWS is often
read outside Emacs).
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75825
; Package
emacs
.
(Mon, 27 Jan 2025 11:49:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 75825 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for the review!
Robert Pluim <rpluim <at> gmail.com> writes:
> As with #75495, "size" or "sizes", please pick one and only one.
I do not have a preference for this. So I updated the patch to use
"sizes" consistently following your comment in #75495.
> When adding a new user option, please describe the default value. I
> assume itʼs nil, but NEWS should tell me (especially as NEWS is often
> read outside Emacs).
Added in the updated patch.
Pengji
[0001-New-user-option-Buffer-menu-human-readable-sizes.patch (text/x-patch, inline)]
From 7b61b6e33804f7aff96777bec008a90760844f8c Mon Sep 17 00:00:00 2001
From: Pengji Zhang <me <at> pengjiz.com>
Date: Mon, 27 Jan 2025 19:42:00 +0800
Subject: [PATCH] New user option 'Buffer-menu-human-readable-sizes'
* lisp/buff-menu.el (Buffer-menu-human-readable-sizes): New user
option.
(list-buffers--refresh): Use it.
* etc/NEWS: Announce the new user option.
---
etc/NEWS | 6 ++++++
lisp/buff-menu.el | 13 ++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 385e943c997..c92fd7722fd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -361,6 +361,12 @@ set to 'title'.
*** New user option 'ibuffer-human-readable-size'.
When non-nil, buffer sizes are shown in human readable format.
+---
+** Buffer Menu
+*** New user option 'Buffer-menu-human-readable-sizes'.
+When non-nil, buffer sizes are shown in human readable format. The
+default is nil, which retains the old format.
+
** Smerge
*** New command 'smerge-extend' extends a conflict over surrounding lines.
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 4418db01724..36268b3512a 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -135,6 +135,14 @@ Buffer-menu-group-sort-by
:group 'Buffer-menu
:version "30.1")
+(defcustom Buffer-menu-human-readable-sizes nil
+ "If non-nil, show buffer sizes in human-readable format.
+That means to use `file-size-human-readable' (which see) to format the
+buffer sizes in the buffer size column."
+ :type 'boolean
+ :group 'Buffer-menu
+ :version "31.1")
+
(defvar-local Buffer-menu-files-only nil
"Non-nil if the current Buffer Menu lists only file buffers.
This is set by the prefix argument to `buffer-menu' and related
@@ -831,7 +839,10 @@ list-buffers--refresh
(if buffer-read-only "%" " ")
(if (buffer-modified-p) "*" " ")
(Buffer-menu--pretty-name name)
- (number-to-string (buffer-size))
+ (funcall (if Buffer-menu-human-readable-sizes
+ #'file-size-human-readable
+ #'number-to-string)
+ (buffer-size))
(concat (format-mode-line mode-name
nil nil buffer)
(if mode-line-process
--
2.48.1
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 01 Feb 2025 10:40:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Pengji Zhang <me <at> pengjiz.com>
:
bug acknowledged by developer.
(Sat, 01 Feb 2025 10:40:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 75825-done <at> debbugs.gnu.org (full text, mbox):
> Cc: 75825 <at> debbugs.gnu.org
> From: Pengji Zhang <me <at> pengjiz.com>
> Date: Mon, 27 Jan 2025 19:48:43 +0800
>
> Thanks for the review!
>
> Robert Pluim <rpluim <at> gmail.com> writes:
>
> > As with #75495, "size" or "sizes", please pick one and only one.
>
> I do not have a preference for this. So I updated the patch to use
> "sizes" consistently following your comment in #75495.
>
> > When adding a new user option, please describe the default value. I
> > assume itʼs nil, but NEWS should tell me (especially as NEWS is often
> > read outside Emacs).
>
> Added in the updated patch.
Thanks, installed on the master branch, and closing the bug.
Please in the future, once the bug number is known (as it always is
when you post a corrected version of a patch), mention the bug number
in the commit log message. Otherwise, I have to add it manually, when
installing the patch.
This bug report was last modified 5 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.