[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/16: ui: 'with-paginated-output-port' gives access to the wrapped port
From: |
guix-commits |
Subject: |
07/16: ui: 'with-paginated-output-port' gives access to the wrapped port. |
Date: |
Mon, 14 Feb 2022 09:53:40 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 7ffcee1937671cbb318491076164fba4ef0b109c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Feb 9 22:21:58 2022 +0100
ui: 'with-paginated-output-port' gives access to the wrapped port.
* guix/ui.scm (pager-port-mapping): New variable.
(pager-wrapped-port): New procedure.
(call-with-paginated-output-port): Parameterize 'pager-port-mapping'.
---
guix/ui.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 093de1b4ab..d1f92ce7be 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -124,6 +124,7 @@
file-hyperlink
location->hyperlink
+ pager-wrapped-port
with-paginated-output-port
relevance
package-relevance
@@ -1665,6 +1666,20 @@ score, the more relevant OBJ is to REGEXPS."
zero means that PACKAGE does not match any of REGEXPS."
(relevance package regexps %package-metrics))
+(define pager-port-mapping
+ ;; If a pager is being used, via 'with-paginated-output-port', this maps the
+ ;; pager port (pipe) to the underlying output port.
+ (make-parameter #f))
+
+(define* (pager-wrapped-port #:optional (port (current-output-port)))
+ "If PORT is a pipe to a pager created by 'with-paginated-output-port',
+return the underlying port. Otherwise return #f."
+ (match (pager-port-mapping)
+ ((pager . wrapped)
+ (and (eq? pager port) wrapped))
+ (_
+ #f)))
+
(define* (call-with-paginated-output-port proc
#:key (less-options "FrX"))
(let ((pager-command-line (or (getenv "GUIX_PAGER")
@@ -1691,7 +1706,10 @@ zero means that PACKAGE does not match any of REGEXPS."
char-set:whitespace))))))
(dynamic-wind
(const #t)
- (lambda () (proc pager))
+ (lambda ()
+ (parameterize ((pager-port-mapping
+ (cons pager (current-output-port))))
+ (proc pager)))
(lambda () (close-pipe pager))))
(proc (current-output-port)))))
- branch master updated (72dd5c8766 -> 41000d16c5), guix-commits, 2022/02/14
- 03/16: gnu: ghc@4: Use 'search-patches'., guix-commits, 2022/02/14
- 02/16: gnu: gcc: Add 2.95., guix-commits, 2022/02/14
- 05/16: gnu: Remove glibc@2.2.5 and gcc-2.95-wrapper., guix-commits, 2022/02/14
- 04/16: gnu: ghc@4: Build without referring to packages in commencement.scm., guix-commits, 2022/02/14
- 06/16: pull: '--list-generations' lists packages only with '--details'., guix-commits, 2022/02/14
- 08/16: ui: 'display-generation' uses color when talking to a pager., guix-commits, 2022/02/14
- 12/16: gnu: fcitx5-gtk: Add GTK 4 support., guix-commits, 2022/02/14
- 07/16: ui: 'with-paginated-output-port' gives access to the wrapped port.,
guix-commits <=
- 14/16: gnu: Add libnitrokey., guix-commits, 2022/02/14
- 15/16: gnu: Add cppcodec., guix-commits, 2022/02/14
- 01/16: gnu: nhc98: Build with the current tool chain., guix-commits, 2022/02/14
- 16/16: gnu: Add nitrokey-app., guix-commits, 2022/02/14
- 09/16: pull: '--list-generations' pipes its output to the pager., guix-commits, 2022/02/14
- 11/16: gnu: elixir: Fix regex for ERTS_BIN substitution., guix-commits, 2022/02/14
- 10/16: gnu: elixir: Fix file name argument to 'search-input-file'., guix-commits, 2022/02/14
- 13/16: gnu: fcitx5-gtk: Split IM module output for different version of GTK., guix-commits, 2022/02/14