From fa99c4bbc7acdb8def9ce14a05aacb73f99fe3b1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 23 Feb 2020 12:42:58 +0100 Subject: ui: (size->number "1.M") is correctly parsed. Reported by Pierre Neidhardt . * guix/ui.scm (size->number)[unit-pos]: Add #\. to CHAR-SET:DIGIT. * tests/ui.scm ("size->number, 1.M"): New test. --- guix/ui.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix/ui.scm') diff --git a/guix/ui.scm b/guix/ui.scm index dce97fb7b9..db932ecacb 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -591,7 +591,8 @@ nicely." \"1MiB\", to a number of bytes. Raise an error if STR could not be interpreted." (define unit-pos - (string-rindex str char-set:digit)) + (string-rindex str + (char-set-union (char-set #\.) char-set:digit))) (define unit (and unit-pos (substring str (+ 1 unit-pos)))) -- cgit v1.2.3 From d7545a6b538813e88195d084f75a3e87065c999e Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 17 Feb 2020 14:16:53 +0100 Subject: ui: Only display link in capable terminals. * guix/ui.scm (display-generation): Display generation path on new line. * guix/scripts/describe.scm (channel-commit-hyperlink): Add TRANSFORMER argument. (display-profile-content): Use TRANSFORMER argument to display URL explicitly when terminal does not support hyperlinks. --- guix/scripts/describe.scm | 15 +++++++++++---- guix/ui.scm | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'guix/ui.scm') diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index f13f221da9..5e00067ef8 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -201,7 +201,11 @@ way and displaying details about the channel's source code." (format #t (G_ " commit: ~a~%") (if (supports-hyperlinks?) (channel-commit-hyperlink channel commit) - commit)))) + commit)) + (when (not (supports-hyperlinks?)) + (format #t (G_ " URL: ~a~%") + (channel-commit-hyperlink channel commit + (lambda (url msg) url)))))) (_ #f))) ;; Show most recently installed packages last. @@ -233,9 +237,12 @@ way and displaying details about the channel's source code." (define* (channel-commit-hyperlink channel #:optional - (commit (channel-commit channel))) + (commit (channel-commit channel)) + (transformer hyperlink)) "Return a hyperlink for COMMIT in CHANNEL, using COMMIT as the hyperlink's -text. The hyperlink links to a web view of COMMIT, when available." +text. The hyperlink links to a web view of COMMIT, when available. +TRANSFORMER is a procedure of 2 arguments, a URI and text, and returns a +string for display." (let* ((url (channel-url channel)) (uri (string->uri url)) (host (and uri (uri-host uri)))) @@ -244,7 +251,7 @@ text. The hyperlink links to a web view of COMMIT, when available." (#f commit) ((_ template) - (hyperlink (template url commit) commit))) + (transformer (template url commit) commit))) commit))) diff --git a/guix/ui.scm b/guix/ui.scm index db932ecacb..371af4e047 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1637,7 +1637,7 @@ DURATION-RELATION with the current time." (let* ((file (generation-file-name profile number)) (link (if (supports-hyperlinks?) (cut file-hyperlink file <>) - identity)) + (cut format #f (G_ "~a~%file: ~a") <> file))) (header (format #f (link (highlight (G_ "Generation ~a\t~a"))) number (date->string -- cgit v1.2.3 From 9b7f9e6f9ba8dc9ea8b99573e0862856ff1b9475 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Mon, 17 Feb 2020 14:38:48 +0100 Subject: ui: Don't truncate search output when inside Emacs. * guix/ui.scm (display-search-results): Loop over all results when INSIDE_EMACS is set. --- guix/ui.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix/ui.scm') diff --git a/guix/ui.scm b/guix/ui.scm index 371af4e047..22a6d6c8e3 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1473,7 +1473,8 @@ them. If PORT is a terminal, print at most a full screen of results." #:hyperlinks? links? #:extra-fields `((relevance . ,score))))))) - (if (and max-rows + (if (and (not (getenv "INSIDE_EMACS")) + max-rows (> (port-line port) first-line) ;print at least one result (> (+ 4 (line-count text) (port-line port)) max-rows)) -- cgit v1.2.3