From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 2b97e83cc1 2/2: Fix off-by-one file size formatting in ls-lisp Date: Sun, 13 Feb 2022 15:40:21 +0200 Message-ID: <838ruerika.fsf@gnu.org> References: <164464970577.18616.16858189491672331595@vcs2.savannah.gnu.org> <20220212070826.4B772C00895@vcs2.savannah.gnu.org> <83y22frjpy.fsf@gnu.org> <83tud3ri2n.fsf@gnu.org> <83r187rhd8.fsf@gnu.org> <83pmnrqo5m.fsf@gnu.org> <87h793yxtm.fsf@gnus.org> <83h793q7r5.fsf@gnu.org> <874k53uen1.fsf@gnus.org> <83ee47q636.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36573"; mail-complaints-to="usenet@ciao.gmane.io" Cc: salutis@me.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: larsi@gnus.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 13 14:44:20 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJFAq-0009LQ-Kt for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Feb 2022 14:44:20 +0100 Original-Received: from localhost ([::1]:60624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJFAp-0006U0-3M for ged-emacs-devel@m.gmane-mx.org; Sun, 13 Feb 2022 08:44:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJF74-0005Yn-Ju for emacs-devel@gnu.org; Sun, 13 Feb 2022 08:40:26 -0500 Original-Received: from [2001:470:142:3::e] (port=35788 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJF73-0008Br-H7; Sun, 13 Feb 2022 08:40:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=QBKl90pW7r/yGpi8/d79jibp6QoMjbbibfLAQigsxEs=; b=mWlMbZjfjOYqiBWENE4K OT71G4pk6BVe/6BKaLCJwUjL5IUcDZrBtfgTpvwkNkMu4nxzWorFW7Re8fHFdtA1etSAKS4lQU3P/ qpSD5pBCubbUEvVcIMe6qyo5tWb9+G4W0WziQKKTrVZsT+JqGnWN7jqtIqeAdN3o6Xt7WEL/CbO34 1tfMog7nThbLVdNFDw58DiQBGUdt/YWMxC++SSyZLBxigmZTK74dQ0koeSGpATGaIOBInWfq89E+Z 4RdTPbsYBYxTN8r+mNlp6SzQX/Ld0yINX4Aspd1hE72xd9+aTupgzkocNYmw+kfwlMP385xrIG5Ul lAaZpf3fuFSF+w==; Original-Received: from [87.69.77.57] (port=4731 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJF73-0004Gb-0q; Sun, 13 Feb 2022 08:40:25 -0500 In-Reply-To: <83ee47q636.fsf@gnu.org> (message from Eli Zaretskii on Sun, 13 Feb 2022 14:55:09 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286212 Archived-At: > Date: Sun, 13 Feb 2022 14:55:09 +0200 > From: Eli Zaretskii > Cc: salutis@me.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org > > > From: Lars Ingebrigtsen > > Cc: Rudolf Adamkovič , > > monnier@iro.umontreal.ca, > > emacs-devel@gnu.org > > Date: Sun, 13 Feb 2022 13:36:50 +0100 > > > > Like I said in an earlier post, my test file is 1029204 bytes. > > > > (file-size-human-readable 1029204) > > -> "1005.1k" > > Ah, okay. So you want to lose accuracy in these cases and just throw > away the fractional part? Why? > > I'm quite sure "ls -lh" still does that, albeit perhaps not with this > specific size. For example, with these sizes: 1124 => 1.1K 4939 => 4.9K 8255 => 8.1K 1188708 => 1.2M 6916144 => 6.6M So how about the patch below: diff --git a/lisp/files.el b/lisp/files.el index cfa1a59..7e62726 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1494,7 +1494,8 @@ file-size-human-readable (or unit "B")) (concat prefix unit)))) (format (if (and (>= (mod file-size 1.0) 0.05) - (< (mod file-size 1.0) 0.95)) + (< (mod file-size 1.0) 0.95) + (< file-size 10)) "%.1f%s%s" "%.0f%s%s") file-size