diff mbox series

[bug#53909,4/4] pull: '--list-generations' pipes its output to the pager.

Message ID 20220209221712.8724-4-ludo@gnu.org
State Accepted
Headers show
Series 'guix pull -l' no longer displays package lists by default | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Feb. 9, 2022, 10:17 p.m. UTC
* guix/scripts/pull.scm (process-query): For 'list-generations queries,
use 'with-paginated-output-port'.
(display-news-entry-title): Pass second argument to 'highlight'.
(display-news-entry): Pass second argument to 'dim'.
---
 guix/scripts/pull.scm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 707f1f0929..7fe738229b 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -279,7 +279,8 @@  (define title
                   (texi->plain-text title))
 
                 ;; When Texinfo markup is invalid, display it as-is.
-                (const title)))))))
+                (const title)))
+             (or (pager-wrapped-port port) port)))))
 
 (define (display-news-entry entry channel language port)
   "Display ENTRY, a <channel-news-entry> from CHANNEL, in LANGUAGE, a language
@@ -291,7 +292,8 @@  (define commit
     (channel-news-entry-commit entry))
 
   (display-news-entry-title entry language port)
-  (format port (dim (G_ "    commit ~a~%"))
+  (format port (dim (G_ "    commit ~a~%")
+                    (or (pager-wrapped-port port) port))
           (if (supports-hyperlinks?)
               (channel-commit-hyperlink channel commit)
               commit))
@@ -673,14 +675,20 @@  (define (list-generations profile numbers)
              (raise (condition (&profile-not-found-error
                                 (profile profile)))))
             ((not pattern)
-             (list-generations profile (profile-generations profile)))
+             (with-paginated-output-port port
+               (with-output-to-port port
+                 (lambda ()
+                   (list-generations profile (profile-generations profile))))))
             ((matching-generations pattern profile)
              =>
              (match-lambda
                (()
                 (exit 1))
                ((numbers ...)
-                (list-generations profile numbers)))))))
+                (with-paginated-output-port port
+                  (with-output-to-port port
+                    (lambda ()
+                      (list-generations profile numbers))))))))))
     (('display-news)
      (display-news profile))))