unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: Eli Zaretskii <eliz@gnu.org>, Oleh Krehel <ohwoeowho@gmail.com>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: [Emacs-diffs] master fd54102: * lisp/files.el (file-size-function): New defcustom
Date: Mon, 22 Jul 2019 17:26:10 +0200	[thread overview]
Message-ID: <B53B40CA-AFF5-4C32-A67C-277FA1F44FB6@acm.org> (raw)
In-Reply-To: <87sgr07d6e.fsf@tcd.ie>

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

20 juli 2019 kl. 20.50 skrev Basil L. Contovounesios <contovob@tcd.ie>:
> 
> New user options in central places like files.el (as opposed to some
> specialised package) usually warrant a RFC so as to establish which need
> they are addressing, whether this need masks some other issue, and
> whether the proposed change covers this need sufficiently well.
> 
> Internal variables can come and go, but user options are user-facing
> contracts that are harder to change or get rid of.

Agreed, and this defcustom (file-size-function) has a much more general-sounding name and description than merited by its effects (which are limited to the "available disk space" number in Dired and that's it).

Attached is a minimal clean-up which remedies some of the flaws, but perhaps we should instead roll back the defcustom and all related changes entirely until a cohesive proposal is forthcoming, as per your and Eli's comments. Fighting it out in the source isn't really going to be productive.


[-- Attachment #2: 0001-Clean-up-file-size-function-with-better-default-valu.patch --]
[-- Type: application/octet-stream, Size: 1675 bytes --]

From e48fd413e4bb70829c4a5783198facdb6422a2b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 22 Jul 2019 17:10:37 +0200
Subject: [PATCH] Clean up file-size-function, with better default value

* lisp/files.el (size-human-readable-iec): New.
(file-size-function): Better default value.  Eliminate lambda.
Better default for custom choice.  Put in group `dired'.
---
 lisp/files.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 70865ebcdf..868e23f0d1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6698,13 +6698,17 @@ directory-free-space-args
 			"ignored, as Emacs uses `file-system-info' instead"
 			"27.1")
 
-(defcustom file-size-function #'file-size-human-readable
+(defun size-human-readable-iec (size)
+  "Human-readable string for SIZE bytes, using IEC prefixes."
+  (file-size-human-readable size 'iec " "))
+
+(defcustom file-size-function #'size-human-readable-iec
   "Function that transforms the number of bytes into a human-readable string."
   :type `(radio
-          (function-item :tag "Default" file-size-human-readable)
-          (function-item :tag "IEC"
-                         ,(lambda (size) (file-size-human-readable size 'iec " ")))
-          (function :tag "Custom function"))
+          (function-item :tag "IEC" size-human-readable-iec)
+          (function-item :tag "Traditional" file-size-human-readable)
+          (function :tag "Custom function" number-to-string))
+  :group 'dired
   :version "27.1")
 
 (defun get-free-disk-space (dir)
-- 
2.20.1 (Apple Git-117)


[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




  reply	other threads:[~2019-07-22 15:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190719165710.17673.32987@vcs0.savannah.gnu.org>
     [not found] ` <20190719165711.741F1206A7@vcs0.savannah.gnu.org>
2019-07-20 16:53   ` [Emacs-diffs] master fd54102: * lisp/files.el (file-size-function): New defcustom Basil L. Contovounesios
2019-07-20 17:06     ` Eli Zaretskii
2019-07-20 17:38       ` Oleh Krehel
2019-07-20 17:45         ` Eli Zaretskii
2019-07-20 17:50           ` Oleh Krehel
2019-07-20 17:56             ` Eli Zaretskii
2019-07-20 18:50         ` Basil L. Contovounesios
2019-07-22 15:26           ` Mattias Engdegård [this message]
2019-07-22 16:15             ` Oleh Krehel
2019-07-22 20:14               ` Stefan Monnier
2019-07-26 10:43                 ` Mattias Engdegård
2019-07-26 14:39                   ` Basil L. Contovounesios
2019-07-26 21:39                     ` Mattias Engdegård
2019-07-22 17:29             ` Eli Zaretskii
2019-07-20 17:30     ` Mattias Engdegård
2019-07-20 18:48       ` Basil L. Contovounesios
2019-07-20 19:06         ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B53B40CA-AFF5-4C32-A67C-277FA1F44FB6@acm.org \
    --to=mattiase@acm.org \
    --cc=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=ohwoeowho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).