GNU bug report logs - #75495
[PATCH] ibuffer: New defcustom `ibuffer-human-readable-size'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Daniel Mendler <mail@HIDDEN>; Keywords: patch; dated Sat, 11 Jan 2025 13:29:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 75495 <at> debbugs.gnu.org:


Received: (at 75495) by debbugs.gnu.org; 19 Jan 2025 12:26:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 07:26:12 2025
Received: from localhost ([127.0.0.1]:45171 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tZUNY-0000ny-Eh
	for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 07:26:12 -0500
Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]:44231)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1tZUNU-0000nh-T2
 for 75495 <at> debbugs.gnu.org; Sun, 19 Jan 2025 07:26:09 -0500
Received: from phl-compute-01.internal (phl-compute-01.phl.internal
 [10.202.2.41])
 by mailfhigh.phl.internal (Postfix) with ESMTP id 34B3C11400CE
 for <75495 <at> debbugs.gnu.org>; Sun, 19 Jan 2025 07:26:03 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-01.internal (MEProxy); Sun, 19 Jan 2025 07:26:03 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengjiz.com; h=
 cc:content-type:content-type:date:date:from:from:in-reply-to
 :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3;
 t=1737289563; x=1737375963; bh=aZIAffMQdUyAI82oiEX5Vf+64gvUUTlf
 DKvqanMARzI=; b=NEevqPiM/zrn8Xmw7QXS4B7ZgEaIqJvAyDuJq5ognIwcTO44
 LTJW6LJXuAQIV1IQ/DG+JTfdvAJ3Mon+qyHcCDbVlAk89AVLdcha0jHJtJZPG3Jh
 mN7xThtgBrs3XtRaMF03+PidOgJAuRAYCivEN6UD/4TJ+Nk4eUStUnRjFaCxQ44T
 kMMZBIeA7b2ZJc5fPLAVGtglvUB0oSMk0KNkos/3GKAN7xQCrqqoIkd9iTzzspBG
 oIoLnm8mfD/u/iMY+9mNnPc/M6xIwwQOLRU2ryCujLBW0/0SyO/Oh6gO4e17sGC6
 sWqPxJ0oeseRtBc2pCHtk32/PekzK5ImnQjGKg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:content-type:date:date
 :feedback-id:feedback-id:from:from:in-reply-to:message-id
 :mime-version:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1737289563; x=
 1737375963; bh=aZIAffMQdUyAI82oiEX5Vf+64gvUUTlfDKvqanMARzI=; b=B
 HLjRGuHhKXpTwAhdyTv/DlmbDrDKoNc0MtoNfr6sz2GFv7cJLmXfnxYx5dp8Jjxi
 jZGwI4oV/9qvb7fPAt2lhe3ilKhTctiC9WbFzj425ou30bfWmSHVGbUWZxfv1IQJ
 rgLItw0UEtUb08v1nAhcKKU5BpYm1Ym7Wx/Oy6Jgk4SBUVkRoxK9paMDrbLnQncC
 RsqLjIhk4FowDcKEwsW30I/zH7JJFOS0lrHbHMA6og6mWVItYioDMtWm6Nzff6mJ
 DuicGEzZf1ADqrtCaKzv+Z0MFy1xKBoelxIm0BwOik2AK2sZ2FZuJ//YC6fpqMIK
 J2wlwVJEwdSMCdjjX1nHg==
X-ME-Sender: <xms:Wu-MZxx950yhb7O6cc_8Sf7qqM9yi30YfKHILl-3WWGpTYZKIf56eQ>
 <xme:Wu-MZxSJvZ5zmxlsLcKBGDQ3pxB_0Rz9iJI3w3m45zC6vagT-89xWmE1IOprF9w7L
 CKP4P1F7QAHdiE7f-Q>
X-ME-Received: <xmr:Wu-MZ7Wtq42Tzn61nW5MoejbjC9ocL1fWreVQtUru_1_5W4NXotZl_3IhDV0>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeijedggedtucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
 rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuff
 fkgggtsehttdertddttddtnecuhfhrohhmpefrvghnghhjihcukghhrghnghcuoehmvges
 phgvnhhgjhhiiidrtghomheqnecuggftrfgrthhtvghrnheptdfhjeekueduleevffelff
 elhfeuueeufeehkeefteeuhfeiffethfdvhfevuedvnecuvehluhhsthgvrhfuihiivgep
 tdenucfrrghrrghmpehmrghilhhfrhhomhepmhgvsehpvghnghhjihiirdgtohhmpdhnsg
 gprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeejheegleeh
 seguvggssghughhsrdhgnhhurdhorhhg
X-ME-Proxy: <xmx:Wu-MZzgA6e27GrWavVptypOCOfLrM9e6WSDmjs7vZtPFGwQet1Q5TA>
 <xmx:Wu-MZzAsS6I1MDLnn9Z1M9m0phtZsBzKzPBrYVDOIpzpC6M-HdY9Fw>
 <xmx:Wu-MZ8KM24CBDPrXwYilbvU2V2TnXaFZdHMepuvDUHXMyEUlip8TYg>
 <xmx:Wu-MZyDMZo-vIPAtXeBH_bJ7JeV0s_Oa__zOkZaIAkNRj8Q8dWvHxw>
 <xmx:W--MZ47amk2-iCxrzN0PfIZblmcZ4ryvqWds-3GD3zjTIiq-65IBRyEM>
Feedback-ID: i16614472:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
 <75495 <at> debbugs.gnu.org>; Sun, 19 Jan 2025 07:26:02 -0500 (EST)
From: Pengji Zhang <me@HIDDEN>
To: 75495 <at> debbugs.gnu.org
Subject: Re: [PATCH] ibuffer: New defcustom `ibuffer-human-readable-size'
Date: Sun, 19 Jan 2025 20:25:58 +0800
Message-ID: <87wmer3s89.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 75495
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Daniel Mendler <mail@HIDDEN> writes:

>+             (or (get-text-property (1- (length s)) 'ibuffer-size s)
>+                 (get-text-property 0 'ibuffer-size s) 0))))

Should we consider centered column as well? I know it sounds unusual,
but for completeness I would like to support that as well.

Maybe we could skip the leading spaces:

      (get-text-property 0 'ibuffer-size (string-trim-left s " +"))

What do you think?

Pengji




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#75495; Package emacs. Full text available.

Message received at 75495 <at> debbugs.gnu.org:


Received: (at 75495) by debbugs.gnu.org; 18 Jan 2025 10:33:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 05:33:39 2025
Received: from localhost ([127.0.0.1]:40338 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tZ695-0002Gt-Dh
	for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 05:33:39 -0500
Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:32995 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <mail@HIDDEN>)
 id 1tZ693-0002Gc-E5
 for 75495 <at> debbugs.gnu.org; Sat, 18 Jan 2025 05:33:38 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=RS60iMTJWIjIjRLVsVMeLVVImrNoreF+vQ7SbAOOV8o=; b=MuN8j/Mirnh9+P+5OhzgNgXvVE
 +oP6MWXokxkYWY0O+ySypc00dmh0GuOeuw5HfEHhgb1U37fJMsfDqNmpMNtYdcw5W0Kg9eYlMF0pl
 NuZ3SuZprw4kTPNDZeg6CFXuF4q4kvZiE3iG0OyI9RKL0vCQSGC4/23PSlqpbZJt17Yk=;
From: Daniel Mendler <mail@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#75495: [PATCH] ibuffer: New defcustom
 `ibuffer-human-readable-size'
In-Reply-To: <86frlgbfdj.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 18 Jan
 2025 12:11:52 +0200")
References: <87ikqlbhug.fsf@HIDDEN>
 <87h664p5wp.fsf@HIDDEN> <86frlgbfdj.fsf@HIDDEN>
Date: Sat, 18 Jan 2025 11:33:30 +0100
Message-ID: <87cygkcsxx.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 75495
Cc: 75495 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain

Eli Zaretskii <eliz@HIDDEN> writes:

>> Date: Sun, 12 Jan 2025 13:34:30 +0100
>> From:  Daniel Mendler via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> 
>> Daniel Mendler <mail@HIDDEN> writes:
>> 
>> > This patch adds the customization option `ibuffer-human-readable-size'.
>> > If customized to t, buffer sizes in Ibuffer are shown in human readable
>> > format.
>> 
>> I have attached an improved version of the patch to this mail, where it
>> is ensured that the summarizer works for a left or right aligned size
>> column.
>
> Thanks.
>
>> +(defcustom ibuffer-human-readable-size nil
>> +  "Show buffer sizes in human-readable format."
>> +  :type 'boolean)
>
> This needs a :version tag.
>
> Also, I think the doc string should explain in more detail what we
> mean by "human-readable format".

Thank you for the review. I have attached an updated patch to this mail.

Daniel


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-ibuffer-New-defcustom-ibuffer-human-readable-size.patch

From 57358674a7c5b5231c6be97546f86838c3413e33 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@HIDDEN>
Date: Sat, 11 Jan 2025 14:22:02 +0100
Subject: [PATCH 1/2] 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.
---
 etc/NEWS        |  3 +++
 lisp/ibuffer.el | 29 ++++++++++++++++++++---------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 0b849dec450..ad099f34541 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -353,6 +353,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.
 
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 32bc8140703..c0033af8435 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -186,6 +186,12 @@ ibuffer-fontification-alist
 		(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 @@ size
   (: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 sum
+             (or (get-text-property (1- (length s)) 'ibuffer-size s)
+                 (get-text-property 0 'ibuffer-size s) 0))))
+       (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)
-- 
2.45.2


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#75495; Package emacs. Full text available.

Message received at 75495 <at> debbugs.gnu.org:


Received: (at 75495) by debbugs.gnu.org; 18 Jan 2025 10:12:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 05:12:03 2025
Received: from localhost ([127.0.0.1]:40277 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tZ5oB-0006YB-5e
	for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 05:12:03 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:57102)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tZ5o9-0006Xc-1q
 for 75495 <at> debbugs.gnu.org; Sat, 18 Jan 2025 05:12:01 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1tZ5o3-00009m-3Z; Sat, 18 Jan 2025 05:11:55 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=lQLmlZpjnm9NipNFHyuwIMCurEkmxw0oYLIBidE5OoQ=; b=cmwYm2ZBeBdy
 Nks671VoYhOchX/BJmdkIMZz4ch8Dp39TGn0y++uXu1+KVYN71tOihBK9uG0glaQUwmOjK2ZUBbxK
 T9pMX2uCsWC9pOR9j6z0xYOa92ZndRnf5nMcgzok333b8s7wWaxsLcRnF/alX7PPej8Qy8EVntXjp
 3vR7+jgckDlbNw3UXuZIM+DY0bor8SHiX+DCwF1g5Qpz/tzTghNXpig5qV7degsCWfuYQA1RNclor
 w9EAcp3i182rTLvQpev22rFP3nqTDtJvF5HtL+PbZlRCYK1v6DOvuLVjqYZP6VYpIE0F9SWDj5tfs
 f04zeIHegJsEF9UBfUWXJQ==;
Date: Sat, 18 Jan 2025 12:11:52 +0200
Message-Id: <86frlgbfdj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <87h664p5wp.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#75495: [PATCH] ibuffer: New defcustom
 `ibuffer-human-readable-size'
References: <87ikqlbhug.fsf@HIDDEN>
 <87h664p5wp.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 75495
Cc: 75495 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sun, 12 Jan 2025 13:34:30 +0100
> From:  Daniel Mendler via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> Daniel Mendler <mail@HIDDEN> writes:
> 
> > This patch adds the customization option `ibuffer-human-readable-size'.
> > If customized to t, buffer sizes in Ibuffer are shown in human readable
> > format.
> 
> I have attached an improved version of the patch to this mail, where it
> is ensured that the summarizer works for a left or right aligned size
> column.

Thanks.

> +(defcustom ibuffer-human-readable-size nil
> +  "Show buffer sizes in human-readable format."
> +  :type 'boolean)

This needs a :version tag.

Also, I think the doc string should explain in more detail what we
mean by "human-readable format".




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#75495; Package emacs. Full text available.

Message received at 75495 <at> debbugs.gnu.org:


Received: (at 75495) by debbugs.gnu.org; 12 Jan 2025 12:34:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 12 07:34:44 2025
Received: from localhost ([127.0.0.1]:46360 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tWxAx-0002cA-Ur
	for submit <at> debbugs.gnu.org; Sun, 12 Jan 2025 07:34:44 -0500
Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:44561 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <mail@HIDDEN>)
 id 1tWxAu-0002bp-M0
 for 75495 <at> debbugs.gnu.org; Sun, 12 Jan 2025 07:34:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:To:From:Sender:Reply-To:Cc:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=fCE30eogx+xjYCe+BxtvfceNyG7IVheGVk/Gl+q89Sc=; b=CJ17oRh2PMdyRJD0rsjZpD9sQf
 cJkIzUER3R24IguA4SWtONJ2oML6z0GUQ5UY/rvohQoBli273vc6td23hiK6iPsgpnxNihidf5pO8
 pKRhuyt9Dg/4mKX1/VLyY7GMZTIJ/83RexeI9E8iS+kA4NR3Y8vuy8uJwoOb98AtSACo=;
From: Daniel Mendler <mail@HIDDEN>
To: 75495 <at> debbugs.gnu.org
Subject: Re: bug#75495: [PATCH] ibuffer: New defcustom
 `ibuffer-human-readable-size'
In-Reply-To: <87ikqlbhug.fsf@HIDDEN> (Daniel Mendler's message of
 "Sat, 11 Jan 2025 14:28:07 +0100")
References: <87ikqlbhug.fsf@HIDDEN>
Date: Sun, 12 Jan 2025 13:34:30 +0100
Message-ID: <87h664p5wp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 75495
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain

Daniel Mendler <mail@HIDDEN> writes:

> This patch adds the customization option `ibuffer-human-readable-size'.
> If customized to t, buffer sizes in Ibuffer are shown in human readable
> format.

I have attached an improved version of the patch to this mail, where it
is ensured that the summarizer works for a left or right aligned size
column.

Daniel


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-ibuffer-New-defcustom-ibuffer-human-readable-size.patch

From 556b043da41f6196072d71cf4dfbc4fd2c1f1695 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@HIDDEN>
Date: Sat, 11 Jan 2025 14:22:02 +0100
Subject: [PATCH 1/2] 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.
---
 etc/NEWS        |  3 +++
 lisp/ibuffer.el | 27 ++++++++++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index d017c872fa3..d20c71897bc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -338,6 +338,9 @@ modal editing packages.
 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.
 
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 32bc8140703..cb69915e6b7 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -186,6 +186,10 @@ ibuffer-fontification-alist
 		(sexp :tag "Test Form")
                 face)))
 
+(defcustom ibuffer-human-readable-size nil
+  "Show buffer sizes in human-readable format."
+  :type 'boolean)
+
 (defcustom ibuffer-use-other-window nil
   "If non-nil, display Ibuffer in another window by default."
   :type 'boolean)
@@ -1714,15 +1718,20 @@ size
   (: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 sum
+             (or (get-text-property (1- (length s)) 'ibuffer-size s)
+                 (get-text-property 0 'ibuffer-size s) 0))))
+       (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)
-- 
2.45.2


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#75495; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Jan 2025 13:28:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 11 08:28:37 2025
Received: from localhost ([127.0.0.1]:41768 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tWbXY-00049Q-Mv
	for submit <at> debbugs.gnu.org; Sat, 11 Jan 2025 08:28:37 -0500
Received: from lists.gnu.org ([2001:470:142::17]:38254)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <mail@HIDDEN>)
 id 1tWbXV-00048h-T7
 for submit <at> debbugs.gnu.org; Sat, 11 Jan 2025 08:28:34 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1tWbXE-0000H1-BD
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2025 08:28:17 -0500
Received: from server.qxqx.de ([2a01:4f8:c012:9177::1] helo=mail.qxqx.de)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1tWbXA-0001NN-DC
 for bug-gnu-emacs@HIDDEN; Sat, 11 Jan 2025 08:28:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date:
 Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=AsDuPL08Ow2ZHItNk8F1pJEO2/mH23pbvDiGoyED2nc=; b=xFmydI0nES42e3UEOOLEv8Mfuw
 2QTotO9VL2OhHkeM2uocvASAiW73kO6CbHxAWnVi7z6GVZMXxlocat9BWQsn8yxBo4saMfoxVt9lV
 MXY6AneiZc4lTIdgKsRGYpuqxeBZcCcM+4dVZjxaPHU/Iiwv1jF6l/Z5mqphRChiZwnk=;
From: Daniel Mendler <mail@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] ibuffer: New defcustom `ibuffer-human-readable-size'
Date: Sat, 11 Jan 2025 14:28:07 +0100
Message-ID: <87ikqlbhug.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a01:4f8:c012:9177::1;
 envelope-from=mail@HIDDEN; helo=mail.qxqx.de
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
Content-Type: text/plain

Tags: patch

This patch adds the customization option `ibuffer-human-readable-size'.
If customized to t, buffer sizes in Ibuffer are shown in human readable
format.


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-ibuffer-New-defcustom-ibuffer-human-readable-size.patch

From e516d867edcfeda4840ba8e067534bc8582ee0e9 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@HIDDEN>
Date: Sat, 11 Jan 2025 14:22:02 +0100
Subject: [PATCH] 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.
---
 etc/NEWS        |  3 +++
 lisp/ibuffer.el | 26 +++++++++++++++++---------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index d017c872fa3..d20c71897bc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -338,6 +338,9 @@ modal editing packages.
 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.
 
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 32bc8140703..65f8ca53693 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -186,6 +186,10 @@ ibuffer-fontification-alist
 		(sexp :tag "Test Form")
                 face)))
 
+(defcustom ibuffer-human-readable-size nil
+  "Show buffer sizes in human-readable format."
+  :type 'boolean)
+
 (defcustom ibuffer-use-other-window nil
   "If non-nil, display Ibuffer in another window by default."
   :type 'boolean)
@@ -1714,15 +1718,19 @@ size
   (: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 sum
+             (or (get-text-property 0 'ibuffer--buffer-size s) 0))))
+       (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--buffer-size size)))
 
 (define-ibuffer-column recency
   (:inline t :summarizer ignore :header-mouse-map ibuffer-recency-header-map)
-- 
2.45.2


--=-=-=--




Acknowledgement sent to Daniel Mendler <mail@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#75495; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 19 Jan 2025 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.