From patchwork Sat Apr 9 20:23:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 38474 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F3C4627BBEA; Sat, 9 Apr 2022 21:25:41 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AE0F727BBE9 for ; Sat, 9 Apr 2022 21:25:41 +0100 (BST) Received: from localhost ([::1]:45620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ndHeO-0008J1-R8 for patchwork@mira.cbaines.net; Sat, 09 Apr 2022 16:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHdq-0007tA-DD for guix-patches@gnu.org; Sat, 09 Apr 2022 16:25:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndHdm-0001H4-Q0 for guix-patches@gnu.org; Sat, 09 Apr 2022 16:25:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ndHdm-0002pQ-L4 for guix-patches@gnu.org; Sat, 09 Apr 2022 16:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54823] [PATCH 1/3] ui: Highlight important bits in recutils output. References: <20220409202224.32040-1-ludo@gnu.org> In-Reply-To: <20220409202224.32040-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 09 Apr 2022 20:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54823 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54823@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54823-submit@debbugs.gnu.org id=B54823.164953585210783 (code B ref 54823); Sat, 09 Apr 2022 20:25:02 +0000 Received: (at 54823) by debbugs.gnu.org; 9 Apr 2022 20:24:12 +0000 Received: from localhost ([127.0.0.1]:38746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHcx-0002nr-M3 for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHcv-0002nU-Co for 54823@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:09 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHcp-000190-Rc; Sat, 09 Apr 2022 16:24:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=ICHw99feEkgiPdbe+BzgJuaOxLr8Mp6zvAGgvrh4eVE=; b=aNVC5GE266jo90 1llh17fSzmwVCuPYg7WaxwR1Svgi6poba8AczKtZdoD53UpTnLLF1l4VXJH8lAyJb/jevE+2gbCB5 paLIbHH7a1qoLv2l557gEgSRRi4r9F/meCCVSZEpr9LDydFOFXxqBa6SGH03Xs526faBuJ4UUy8Dr BCEmSv+aGZMySU0NCiLVg7z3c1ykd7cNPyv0LsrjClQJrFc8ShqSJexMM0w+selPKr2nwoIZgq2vS WnFdAQ2rDA2Sed+5acBIaQ/F10QTd7cAMILaxjjV/zv+0ZZvmeS7DzF3TKLCO2RY3MRNhH2XCARqJ uQUX+cZFzmtYdf2p4cvQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58105 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndHco-0004pO-KZ; Sat, 09 Apr 2022 16:24:03 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 9 Apr 2022 22:23:42 +0200 Message-Id: <20220409202344.32090-1-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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