From fde1783087ba93fcadc4b26bd4611ae03626d105 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 1 Oct 2015 11:28:58 +0200 Subject: download: Check whether HORIZONTAL ELLIPSIS can be encoded. * guix/build/download.scm (ellipsis): New procedure. (store-path-abbreviation): Use it. --- guix/build/download.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/guix/build/download.scm b/guix/build/download.scm index 4b7c53d2c6..240e79ee8d 100644 --- a/guix/build/download.scm +++ b/guix/build/download.scm @@ -110,6 +110,13 @@ column." (padding (make-string num-spaces #\space))) (string-append left padding right))) +(define* (ellipsis #:optional (port (current-output-port))) + "Make a rough guess at whether Unicode's HORIZONTAL ELLIPSIS can be written +in PORT's encoding, and return either that or ASCII dots." + (if (equal? (port-encoding port) "UTF-8") + "…" + "...")) + (define* (store-path-abbreviation store-path #:optional (prefix-length 6)) "If STORE-PATH is the file name of a store entry, return an abbreviation of STORE-PATH for display, showing PREFIX-LENGTH characters of the hash. @@ -117,7 +124,7 @@ Otherwise return STORE-PATH." (if (string-prefix? (%store-directory) store-path) (let ((base (basename store-path))) (string-append (string-take base prefix-length) - "…" + (ellipsis) (string-drop base 32))) store-path)) -- cgit 1.4.1