diff options
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 3bc82111a5..163042054c 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -121,6 +121,7 @@ relevance package-relevance display-search-results + display-package-search-results %package-metrics with-profile-lock @@ -1490,6 +1491,40 @@ to view all the results.") (() #t)))) +(define* (display-package-search-results search-results port + #:key + (command "guix search")) + "Display SEARCH-RESULTS, a list of search result texts each corresponding to +one matching package. If PORT is a terminal, print at most a full screen of +results." + (define first-line + (port-line port)) + + (define max-rows + (and first-line (isatty? port) + (terminal-rows port))) + + (define (line-count str) + (string-count str #\newline)) + + (let loop ((search-results search-results)) + (match search-results + ((text rest ...) + (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)) + (unless (null? rest) + (display-hint (format #f (G_ "Run @code{~a ... | less} \ +to view all the results.") + command))) + (begin + (display text port) + (loop rest)))) + (() + #t)))) + (define (string->generations str) "Return the list of generations matching a pattern in STR. This function |