From: "Ludovic Courtès" <ludo@gnu.org>
To: 54823@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#54823] [PATCH 1/3] ui: Highlight important bits in recutils output.
Date: Sat, 9 Apr 2022 22:23:42 +0200 [thread overview]
Message-ID: <20220409202344.32090-1-ludo@gnu.org> (raw)
In-Reply-To: <20220409202224.32040-1-ludo@gnu.org>
* guix/scripts/system/search.scm (service-type->recutils): Highlight the
value of the 'name' field.
* guix/ui.scm (package->recutils): Likewise for 'name' and 'version'.
---
guix/scripts/system/search.scm | 9 +++++++--
guix/ui.scm | 7 +++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/guix/scripts/system/search.scm b/guix/scripts/system/search.scm
index 93c9fc5644..2a237e03d9 100644
--- a/guix/scripts/system/search.scm
+++ b/guix/scripts/system/search.scm
@@ -20,7 +20,7 @@
(define-module (guix scripts system search)
#:use-module (guix ui)
#:use-module (guix utils)
- #:autoload (guix colors) (supports-hyperlinks?)
+ #:autoload (guix colors) (highlight supports-hyperlinks?)
#:autoload (guix diagnostics) (location->hyperlink)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
@@ -74,6 +74,9 @@ (define* (service-type->recutils type port
"Write to PORT a recutils record of TYPE, arranging to fit within WIDTH
columns. When HYPERLINKS? is true, emit hyperlink escape sequences when
appropriate."
+ (define port*
+ (or (pager-wrapped-port port) port))
+
(define width*
;; The available number of columns once we've taken into account space for
;; the initial "+ " prefix.
@@ -88,7 +91,9 @@ (define (extensions->recutils extensions)
(string-length "extends: ")))))
;; Note: Don't i18n field names so that people can post-process it.
- (format port "name: ~a~%" (service-type-name type))
+ (format port "name: ~a~%"
+ (highlight (symbol->string (service-type-name type))
+ port*))
(format port "location: ~a~%"
(or (and=> (service-type-location type)
(if hyperlinks? location->hyperlink location->string))
diff --git a/guix/ui.scm b/guix/ui.scm
index 37d24030e4..555a614faa 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1489,6 +1489,9 @@ (define* (package->recutils p port #:optional (width (%text-width))
"Write to PORT a `recutils' record of package P, arranging to fit within
WIDTH columns. EXTRA-FIELDS is a list of symbol/value pairs to emit. When
HYPERLINKS? is true, emit hyperlink escape sequences when appropriate."
+ (define port*
+ (or (pager-wrapped-port port) port))
+
(define width*
;; The available number of columns once we've taken into account space for
;; the initial "+ " prefix.
@@ -1508,8 +1511,8 @@ (define (package<? p1 p2)
(string<? (package-full-name p1) (package-full-name p2)))
;; Note: Don't i18n field names so that people can post-process it.
- (format port "name: ~a~%" (package-name p))
- (format port "version: ~a~%" (package-version p))
+ (format port "name: ~a~%" (highlight (package-name p) port*))
+ (format port "version: ~a~%" (highlight (package-version p) port*))
(format port "outputs: ~a~%" (string-join (package-outputs p)))
(format port "systems: ~a~%"
(split-lines (string-join (package-transitive-supported-systems p))
--
2.35.1
next prev parent reply other threads:[~2022-04-09 20:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 20:22 [bug#54823] [PATCH 0/3] Highlight keywords in search results Ludovic Courtès
2022-04-09 20:23 ` Ludovic Courtès [this message]
2022-04-09 20:23 ` [bug#54823] [PATCH 2/3] colors: Add 'colorize-full-matches' Ludovic Courtès
2022-04-09 20:23 ` [bug#54823] [PATCH 3/3] ui: Highlight package and service search results Ludovic Courtès
2022-04-19 16:09 ` bug#54823: [PATCH 0/3] Highlight keywords in " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220409202344.32090-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=54823@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).