summaryrefslogtreecommitdiff
path: root/lisp/url
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-05-13 17:05:24 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2019-06-23 20:30:50 +0200
commit866f527ddf21050a827fa47e04cfe6163f1c7053 (patch)
tree411dae7879dc84717f0bfd11087633d32762b5a7 /lisp/url
parentb439b3bb5a44bc61cec3f5c8e3e3ea37760dfb29 (diff)
downloademacs-866f527ddf21050a827fa47e04cfe6163f1c7053.tar.gz
Optional space and unit in `file-size-human-readable' (bug#35756)
To improve readability of strings produced by `file-size-human-readable', add two optional arguments: - SPACE, to provide a string (typically a space or non-breaking space) to put between the number and unit. For compatibility, the default is an empty string. - UNIT, a string to use as unit. For compatibility, the default is "B" in `iec' mode and the empty string otherwise. Also fix a glitch with small numbers in `iec' mode which caused a stray "i" in the result. * lisp/files.el (file-size-human-readable): Add optional SPACE and UNIT arguments and handle small numbers correctly. (files--ask-user-about-large-file, warn-maybe-out-of-memory): Call with `iec' and space. * test/lisp/files-tests.el (files-test-file-size-human-readable): New test. * lisp/url/url-http.el (url-http-simple-after-change-function) (url-http-content-length-after-change-function): Call with `iec' and space. * etc/NEWS (Lisp Changes): Mention the change.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/url-http.el11
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 00803a103a0..527760118d4 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -1016,7 +1016,8 @@ should be shown to the user."
(defun url-http-simple-after-change-function (_st _nd _length)
;; Function used when we do NOT know how long the document is going to be
;; Just _very_ simple 'downloaded %d' type of info.
- (url-lazy-message "Reading %s..." (file-size-human-readable (buffer-size))))
+ (url-lazy-message "Reading %s..."
+ (file-size-human-readable (buffer-size) 'iec " ")))
(defun url-http-content-length-after-change-function (_st nd _length)
"Function used when we DO know how long the document is going to be.
@@ -1029,16 +1030,16 @@ the callback to be triggered."
(url-percentage (- nd url-http-end-of-headers)
url-http-content-length)
url-http-content-type
- (file-size-human-readable (- nd url-http-end-of-headers))
- (file-size-human-readable url-http-content-length)
+ (file-size-human-readable (- nd url-http-end-of-headers) 'iec " ")
+ (file-size-human-readable url-http-content-length 'iec " ")
(url-percentage (- nd url-http-end-of-headers)
url-http-content-length))
(url-display-percentage
"Reading... %s of %s (%d%%)"
(url-percentage (- nd url-http-end-of-headers)
url-http-content-length)
- (file-size-human-readable (- nd url-http-end-of-headers))
- (file-size-human-readable url-http-content-length)
+ (file-size-human-readable (- nd url-http-end-of-headers) 'iec " ")
+ (file-size-human-readable url-http-content-length 'iec " ")
(url-percentage (- nd url-http-end-of-headers)
url-http-content-length)))