From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 09 16:22:43 2022 Received: (at submit) by debbugs.gnu.org; 9 Apr 2022 20:22:43 +0000 Received: from localhost ([127.0.0.1]:38736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHbT-0002kR-QT for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:22:43 -0400 Received: from lists.gnu.org ([209.51.188.17]:57586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHbS-0002kK-Gv for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHbS-0005V0-Bw for guix-patches@gnu.org; Sat, 09 Apr 2022 16:22:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHbS-0000xa-2T; Sat, 09 Apr 2022 16:22:38 -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=HPBICSZzExUkOjI3mvjmmIjQHBdKBRaGpZ6r1+/jhjo=; b=VxGwtL+/MRuHCW O7WIg8hxJbhl34QUJcMbQW/Hu2zF3MFP5xKD5ZH0Sbdnhs+Ku1d2t0JiBdqMWP8ePXVdLyfx/5GVC IqIsNbxyl/tcdxI8bZB1QHtfAEpZfqsjOq0PmVl/JBY3II9jZaH+sZVkwCckbFrfRA2QwY8RIS8UP efbx+hRPaxXDRFHIFEROu4oqkAmz4qhI1OneWE1qj9ccfue57UTTCVXZWMI6FJFMlFGDLnfh6SAVq gDqbaC4uKgg2WYRDOmdhfRSzduusrWF9XTGVMZxCfvNcUtuyxx9QOYSr9EoXseJ5KPn2qO8J6IkoY rSDHq2ucGc07prU8ihow==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:65263 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 1ndHbR-0004kJ-KH; Sat, 09 Apr 2022 16:22:37 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/3] Highlight keywords in search results Date: Sat, 9 Apr 2022 22:22:24 +0200 Message-Id: <20220409202224.32040-1-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! In the quest for colorful output, one thing I’ve always missed is keyword highlighting in the search results in ‘guix search’, ‘guix system search’, and ‘guix home search’. The last patch does that; the first one highlights the ‘name’ and ‘version’ field of the recutils output. Thoughts? Ludo’. Ludovic Courtès (3): ui: Highlight important bits in recutils output. colors: Add 'colorize-full-matches'. ui: Highlight package and service search results. guix/colors.scm | 22 ++++++++++++ guix/scripts/home.scm | 1 + guix/scripts/package.scm | 3 +- guix/scripts/system/search.scm | 37 +++++++++++++------- guix/ui.scm | 64 +++++++++++++++++++++++----------- 5 files changed, 93 insertions(+), 34 deletions(-) base-commit: 0996d48d0e79a360e0d5583b812cd565f62ca32e -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 09 16:24:12 2022 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: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 54823@debbugs.gnu.org Subject: [PATCH 1/3] ui: Highlight important bits in recutils output. 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 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 54823 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * 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) id 1ndHd0-0002o0-0j for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHcw-0002na-Uu for 54823@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHcr-00019Q-Nu; Sat, 09 Apr 2022 16:24:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=tSLsbOfsvB/ioBLaz5CX73+dh3ZrTyt+7F3n5tCGacI=; b=oshUlNHR6HCp6TBUECRE /YlFIHcEMZD0s634ALhWP/17dnm88nfDUf5TjMEN0qs/ES2vPrQulcP6JjIKqj6olXYIfvWZGxJE+ ucKSo1VZAcZw6vFMddH1g0+CULc14qTgw2g7CjUYXcGAeUFCVljqRG/SZO/VxweOxZ3vsmY1Qt3ar BcWfDjlfpXbpxtDB/i0yD8pEvN/akH+Lfmnb58zPhyDA0GHsmjRtYhYQV0rn2+WAm7ACBEvuESrWE aFfuH+bYBggHyrS4LC8jnoWe0uABOe4qPnrn0v5mgR5dwT9Nq5FP7ELSqyQJXCPIDnmcnERpJNIOJ DEqSNz3yuT2TQQ==; 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 1ndHcr-0004pO-2k; Sat, 09 Apr 2022 16:24:05 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 54823@debbugs.gnu.org Subject: [PATCH 3/3] ui: Highlight package and service search results. Date: Sat, 9 Apr 2022 22:23:44 +0200 Message-Id: <20220409202344.32090-3-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220409202344.32090-1-ludo@gnu.org> References: <20220409202344.32090-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 54823 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/ui.scm (package->recutils): Add #:highlighting parameter and use it. (display-search-results): Add #:regexps parameter; call 'colorize-full-matches' and pass #:highlighting. * guix/scripts/package.scm (process-query): Pass #:regexps to 'display-search-results'. * guix/scripts/home.scm (search): Likewise. * guix/scripts/system/search.scm (service-type->recutils): Add #:highlighting parameter and use it. --- guix/scripts/home.scm | 1 + guix/scripts/package.scm | 3 +- guix/scripts/system/search.scm | 30 +++++++++++------- guix/ui.scm | 57 ++++++++++++++++++++++------------ 4 files changed, 60 insertions(+), 31 deletions(-) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 341d83943d..f43bf865a7 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -733,6 +733,7 @@ (define (search . args) (leave-on-EPIPE (display-search-results matches (current-output-port) #:print service-type->recutils + #:regexps regexps #:command "guix home search"))))) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 22ee8a2485..d007005607 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -885,7 +885,8 @@ (define (diff-profiles profile numbers) (regexps (map (cut make-regexp* <> regexp/icase) patterns)) (matches (find-packages-by-description regexps))) (leave-on-EPIPE - (display-search-results matches (current-output-port))) + (display-search-results matches (current-output-port) + #:regexps regexps)) #t)) (('show _) diff --git a/guix/scripts/system/search.scm b/guix/scripts/system/search.scm index 2a237e03d9..d70ed266f4 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) (highlight supports-hyperlinks?) + #:autoload (guix colors) (color-output? highlight supports-hyperlinks?) #:autoload (guix diagnostics) (location->hyperlink) #:use-module (gnu services) #:use-module (gnu services shepherd) @@ -70,10 +70,12 @@ (define* (service-type->recutils type port #:optional (width (%text-width)) #:key (extra-fields '()) - (hyperlinks? (supports-hyperlinks? port))) + (hyperlinks? (supports-hyperlinks? port)) + (highlighting identity)) "Write to PORT a recutils record of TYPE, arranging to fit within WIDTH columns. When HYPERLINKS? is true, emit hyperlink escape sequences when -appropriate." +appropriate. Pass the description through HIGHLIGHTING, a one-argument +procedure that may return a colorized version of its argument." (define port* (or (pager-wrapped-port port) port)) @@ -90,6 +92,11 @@ (define (extensions->recutils extensions) (fill-paragraph list width* (string-length "extends: "))))) + (define highlighting* + (if (color-output? port*) + highlighting + identity)) + ;; Note: Don't i18n field names so that people can post-process it. (format port "name: ~a~%" (highlight (symbol->string (service-type-name type)) @@ -114,14 +121,15 @@ (define (extensions->recutils extensions) (when (service-type-description type) (format port "~a~%" - (string->recutils - (string-trim-right - (parameterize ((%text-width width*)) - (texi->plain-text - (string-append "description: " - (or (and=> (service-type-description type) P_) - "")))) - #\newline)))) + (highlighting* + (string->recutils + (string-trim-right + (parameterize ((%text-width width*)) + (texi->plain-text + (string-append "description: " + (or (and=> (service-type-description type) P_) + "")))) + #\newline))))) (for-each (match-lambda ((field . value) diff --git a/guix/ui.scm b/guix/ui.scm index 555a614faa..cb68a07c6c 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1485,10 +1485,13 @@ (define (string->recutils str) (define* (package->recutils p port #:optional (width (%text-width)) #:key (hyperlinks? (supports-hyperlinks? port)) - (extra-fields '())) + (extra-fields '()) + (highlighting identity)) "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." +HYPERLINKS? is true, emit hyperlink escape sequences when appropriate. Pass +the synopsis and description through HIGHLIGHTING, a one-argument procedure +that may return a colorized version of its argument." (define port* (or (pager-wrapped-port port) port)) @@ -1510,6 +1513,11 @@ (define (dependencies->recutils packages) (define (packagerecutils - (string-trim-right - (parameterize ((%text-width width*)) - ;; Call 'texi->plain-text' on the concatenated string to account - ;; for the width of "description:" in paragraph filling. - (texi->plain-text* - p - (string-append "description: " - (or (and=> (package-description p) P_) - "")))) - #\newline))) + (highlighting* + (string->recutils + (string-trim-right + (parameterize ((%text-width width*)) + ;; Call 'texi->plain-text' on the concatenated string to account + ;; for the width of "description:" in paragraph filling. + (texi->plain-text* + p + (string-append "description: " + (or (and=> (package-description p) P_) + "")))) + #\newline)))) (for-each (match-lambda ((field . value) (let ((field (symbol->string field))) @@ -1707,10 +1717,12 @@ (define-syntax with-paginated-output-port (define* (display-search-results matches port #:key + (regexps '()) (command "guix search") (print package->recutils)) "Display MATCHES, a list of object/score pairs, by calling PRINT on each of -them. If PORT is a terminal, print at most a full screen of results." +them. If PORT is a terminal, print at most a full screen of results. REGEXPS +is a list of regexps to highlight in search results." (define first-line (port-line port)) @@ -1721,6 +1733,12 @@ (define max-rows (define (line-count str) (string-count str #\newline)) + (define highlighting + (let ((match-color (color ON-RED BOLD))) + (colorize-full-matches (map (lambda (regexp) + (cons regexp match-color)) + regexps)))) + (with-paginated-output-port paginated (let loop ((matches matches)) (match matches @@ -1728,7 +1746,8 @@ (define (line-count str) (let* ((links? (supports-hyperlinks? port))) (print package paginated #:hyperlinks? links? - #:extra-fields `((relevance . ,score))) + #:extra-fields `((relevance . ,score)) + #:highlighting highlighting) (loop rest))) (() #t))))) -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 09 16:24:27 2022 Received: (at 54823) by debbugs.gnu.org; 9 Apr 2022 20:24:27 +0000 Received: from localhost ([127.0.0.1]:38750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHdC-0002oV-H6 for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHcw-0002nW-2s for 54823@debbugs.gnu.org; Sat, 09 Apr 2022 16:24:25 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHcq-00019D-SK; Sat, 09 Apr 2022 16:24:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=KWSC9tQImhYSyjPeKeFnX3+JHLwlWqc4xophC5mie/s=; b=EA5n2nB4oqrqLR9fomSU Nz7apqzSShZzghfFXFnokVmZqZFWQv6tI/1ughvz/VNumjsD9zER/gOiai09G7lyo6sNcC10UCVe5 xNIabDZjm6AbO0Az/nt1HtSLRowVRNdsgsPH4tFZtFkrMSXNGg1RiDON+T1UkKX0Uh9ktZ9AZNk92 cS5sKWD9nphINhrlepFtKRqgJbG37vs3tx6yTd5+OBguFdFOndn3Re6d3LaSdnYs3PHG9pYjGO3YJ FAoso+YIgZpklqF7Amca4LWgncrXksm92O9CDqJkgaW/7upQ/2v7zGBn47dz2KMspiiTQx3SgseJK mt6Mw5kMiO1XBg==; 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 1ndHcq-0004pO-2I; Sat, 09 Apr 2022 16:24:04 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 54823@debbugs.gnu.org Subject: [PATCH 2/3] colors: Add 'colorize-full-matches'. Date: Sat, 9 Apr 2022 22:23:43 +0200 Message-Id: <20220409202344.32090-2-ludo@gnu.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220409202344.32090-1-ludo@gnu.org> References: <20220409202344.32090-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 54823 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/colors.scm (colorize-full-matches): New procedure. --- guix/colors.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/guix/colors.scm b/guix/colors.scm index 3fd36c68ef..543f4c3ec5 100644 --- a/guix/colors.scm +++ b/guix/colors.scm @@ -36,6 +36,7 @@ (define-module (guix colors) highlight/warn dim + colorize-full-matches color-rules color-output? isatty?* @@ -153,6 +154,27 @@ (define highlight (coloring-procedure (color BOLD))) (define highlight/warn (coloring-procedure (color BOLD MAGENTA))) (define dim (coloring-procedure (color DARK))) +(define (colorize-full-matches rules) + "Return a procedure that, given a string, colorizes according to RULES. +RULES must be a list of regexp/color pairs; the whole match of a regexp is +colorized with the corresponding color." + (define proc + (lambda (str) + (if (string-index str #\nul) + str + (let loop ((rules rules)) + (match rules + (() + str) + (((regexp . color) . rest) + (match (regexp-exec regexp str) + (#f (loop rest)) + (m (string-append (proc (match:prefix m)) + (colorize-string (match:substring m) + color) + (proc (match:suffix m))))))))))) + proc) + (define (colorize-matches rules) "Return a procedure that, when passed a string, returns that string colorized according to RULES. RULES must be a list of tuples like: -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 19 12:10:05 2022 Received: (at 54823-done) by debbugs.gnu.org; 19 Apr 2022 16:10:05 +0000 Received: from localhost ([127.0.0.1]:43973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngqQX-000135-53 for submit@debbugs.gnu.org; Tue, 19 Apr 2022 12:10:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngqQT-00011r-5X for 54823-done@debbugs.gnu.org; Tue, 19 Apr 2022 12:10:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngqQO-0003aq-0P for 54823-done@debbugs.gnu.org; Tue, 19 Apr 2022 12:09:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=Y49GfaeEQ7V7yXJskmU5YxrjstrxHfDgnX5sT8WBe98=; b=hSjiQI6zq0DLKulkRoCY +A2PP3nk+VKkA0FPl7F7EvbZm1/LWOSgWvQQv0WxJGC8erAkuw5n6dKA59JnOGwHvDyW0MLOuOcXs m0oRAqXgBhJcSp938BawhA2F/qNnx5NqWa79rWjI6Hgk9I2TNiAci6mbcUxdYqE5g9EXQdsm0Zlfr CW+6S+oYX/GW573Ov+Ez9mMdR2v4wVGo8Y8ROKu+BCo/3gLcfIqCWsKBhXl6Gbr4tLeZ9f0FNd13R hr8qaF053LmtfIeHUI3jjU2Ri103YjxTm7Y+i3yLfEaMMmo+53Utnw4QrAhHSQhlcaHKiVBspMcUb lCgQ35MRAJfs9Q==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=48948 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngqQN-0006Uq-3a for 54823-done@debbugs.gnu.org; Tue, 19 Apr 2022 12:09:55 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 54823-done@debbugs.gnu.org Subject: Re: bug#54823: [PATCH 0/3] Highlight keywords in search results References: <20220409202224.32040-1-ludo@gnu.org> Date: Tue, 19 Apr 2022 18:09:53 +0200 In-Reply-To: <20220409202224.32040-1-ludo@gnu.org> ("Ludovic =?utf-8?Q?Cou?= =?utf-8?Q?rt=C3=A8s=22's?= message of "Sat, 9 Apr 2022 22:22:24 +0200") Message-ID: <87czhdqcku.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 54823-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Pushed! 5e0c347975 ui: Highlight package and service search results. d08e4d52a3 colors: Add 'colorize-full-matches'. 00dcfb261b ui: Highlight important bits in recutils output. From unknown Sat Jun 21 03:20:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 18 May 2022 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator