unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: 58660@debbugs.gnu.org
Cc: othacehe@gnu.org, zimoun <zimon.toutoune@gmail.com>
Subject: [bug#58660] [PATCH v2 3/3] etc: teams: Improve display of regular expression in 'scope' field.
Date: Thu, 17 Nov 2022 21:28:20 +0100	[thread overview]
Message-ID: <20221117202820.2054593-3-zimon.toutoune@gmail.com> (raw)
In-Reply-To: <20221117202820.2054593-1-zimon.toutoune@gmail.com>

* etc/teams.scm.in (<regexp*>): New record type.
(make-regexp*, regexp-exec*): New procedures.
(python, haskell, julia, java, emacs, rust, core, translations, installer,
home): Use it.
(find-team-by-scope): Use it.
(list-teams): Use it.
---
 etc/teams.scm.in | 59 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 41 insertions(+), 18 deletions(-)

diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index 3f90e0e6f2..3bdf91597f 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -38,6 +38,25 @@
              (guix ui)
              (git))
 
+;;; Work around regexp implementation.
+;;; This record allows to track the regexp pattern and then display it.
+(define-record-type <regexp*>
+  (regexp* pat flag)
+  regexp*?
+  (pat regexp-pattern*)
+  (flag regexp-flag*))
+
+(define* (make-regexp* pat #:optional flag)
+  (regexp* pat flag))
+
+(define (regexp-exec* rx* str)
+  (let ((rx (make-regexp
+             (regexp-pattern* rx*)
+             (or (regexp-flag* rx*)
+                 regexp/extended))))
+    (regexp-exec rx str)))
+
+\f
 (define-record-type <team>
   (make-team id name description members scope)
   team?
@@ -98,7 +117,7 @@ (define-team python
         (list "gnu/packages/django.scm"
               "gnu/packages/jupyter.scm"
               ;; Match haskell.scm and haskell-*.scm.
-              (make-regexp "^gnu/packages/python(-.+|)\\.scm$")
+              (make-regexp* "^gnu/packages/python(-.+|)\\.scm$")
               "gnu/packages/sphinx.scm"
               "gnu/packages/tryton.scm"
               "guix/build/pyproject-build-system.scm"
@@ -118,7 +137,7 @@ (define-team haskell
         #:scope
         (list "gnu/packages/dhall.scm"
               ;; Match haskell.scm and haskell-*.scm.
-              (make-regexp "^gnu/packages/haskell(-.+|)\\.scm$")
+              (make-regexp* "^gnu/packages/haskell(-.+|)\\.scm$")
               "gnu/packages/purescript.scm"
               "guix/build/haskell-build-system.scm"
               "guix/build-system/haskell.scm"
@@ -146,7 +165,7 @@ (define-team julia
         #:name "Julia team"
         #:description
         "The Julia language, Julia packages, and the julia-build-system."
-        #:scope (list (make-regexp "^gnu/packages/julia(-.+|)\\.scm$")
+        #:scope (list (make-regexp* "^gnu/packages/julia(-.+|)\\.scm$")
                       "guix/build/julia-build-system.scm"
                       "guix/build-system/julia.scm")))
 
@@ -175,14 +194,14 @@ (define-team java
 and the maven-build-system."
         #:scope
         (list ;; Match java.scm and java-*.scm.
-              (make-regexp "^gnu/packages/java(-.+|)\\.scm$")
+              (make-regexp* "^gnu/packages/java(-.+|)\\.scm$")
               ;; Match maven.scm and maven-*.scm
-              (make-regexp "^gnu/packages/maven(-.+|)\\.scm$")
+              (make-regexp* "^gnu/packages/maven(-.+|)\\.scm$")
               "guix/build/ant-build-system.scm"
               "guix/build/java-utils.scm"
               "guix/build/maven-build-system.scm"
               ;; The maven directory
-              (make-regexp "^guix/build/maven/")
+              (make-regexp* "^guix/build/maven/")
               "guix/build-system/ant.scm"
               "guix/build-system/maven.scm")))
 
@@ -195,7 +214,7 @@ (define-team emacs
         #:name "Emacs team"
         #:description "The extensible, customizable text editor and its
 ecosystem."
-        #:scope (list (make-regexp "^gnu/packages/emacs(-.+|)\\.scm$")
+        #:scope (list (make-regexp* "^gnu/packages/emacs(-.+|)\\.scm$")
                       "guix/build/emacs-build-system.scm"
                       "guix/build/emacs-utils.scm"
                       "guix/build-system/emacs.scm"
@@ -209,7 +228,7 @@ (define-team lisp
         #:description
         "Common Lisp and similar languages, Common Lisp packages and the
 asdf-build-system."
-        #:scope (list (make-regexp "^gnu/packages/lisp(-.+|)\\.scm$")
+        #:scope (list (make-regexp* "^gnu/packages/lisp(-.+|)\\.scm$")
                       "guix/build/asdf-build-system.scm"
                       "guix/build/lisp-utils.scm"
                       "guix/build-system/asdf.scm")))
@@ -241,7 +260,7 @@ (define-team embedded-bootstrap
 (define-team rust
   (team 'rust
         #:name "Rust"
-        #:scope (list (make-regexp "^gnu/packages/(crates|rust)(-.+|)\\.scm$")
+        #:scope (list (make-regexp* "^gnu/packages/(crates|rust)(-.+|)\\.scm$")
                       "guix/build/cargo-build-system.scm"
                       "guix/build/cargo-utils.scm"
                       "guix/build-system/cargo.scm"
@@ -339,9 +358,9 @@ (define-team core
               "guix/upstream.scm"
               "guix/utils.scm"
               "guix/workers.scm"
-              (make-regexp "^guix/platforms/")
-              (make-regexp "^guix/scripts/")
-              (make-regexp "^guix/store/"))))
+              (make-regexp* "^guix/platforms/")
+              (make-regexp* "^guix/scripts/")
+              (make-regexp* "^guix/store/"))))
 
 (define-team games
   (team 'games
@@ -358,17 +377,17 @@ (define-team translations
   (team 'translations
         #:name "Translations"
         #:scope (list "etc/news.scm"
-                      (make-regexp "^po/"))))
+                      (make-regexp* "^po/"))))
 
 (define-team installer
   (team 'installer
         #:name "Installer script and system installer"
-        #:scope (list (make-regexp "^gnu/installer(\\.scm$|/)"))))
+        #:scope (list (make-regexp* "^gnu/installer(\\.scm$|/)"))))
 
 (define-team home
   (team 'home
         #:name "Team for \"Guix Home\""
-        #:scope (list (make-regexp "^(gnu|guix/scripts)/home(\\.scm$|/)")
+        #:scope (list (make-regexp* "^(gnu|guix/scripts)/home(\\.scm$|/)")
                       "tests/guix-home.sh"
                       "tests/home-import.scm"
                       "tests/home-services.scm")))
@@ -508,8 +527,8 @@ (define (find-team-by-scope files)
                 (any (match-lambda
                        ((? string? scope)
                         (string=? scope file))
-                       ((? regexp? scope)
-                        (regexp-exec scope file)))
+                       ((? regexp*? scope)
+                        (regexp-exec* scope file)))
                      (team-scope team)))
               files)
          (cons team acc)
@@ -568,7 +587,11 @@ (define width* (%text-width))
                    (string-append fmt str))
                  (format #f "scope:~%")
                  (sort
-                  (map (lambda (scope) (format #f "+ ~a~%" scope)) scope-files)
+                  (map (compose (cut format #f "+ ~a~%" <>)
+                                (match-lambda
+                                  ((? regexp*? rx*) (regexp-pattern* rx*))
+                                  ((? string? str) str)))
+                       scope-files)
                   string<=?)))))
      (list-members team port* "+ ")
      (newline))
-- 
2.38.1





  parent reply	other threads:[~2022-11-17 20:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221020132140.1546684-1-zimon.toutoune@gmail.com>
2022-10-20 13:28 ` [bug#58660] [PATCH 1/4] etc: teams: Improve scope display zimoun
2022-10-20 13:28   ` [bug#58660] [PATCH 3/4] etc: teams: List teams sorted by id zimoun
2022-10-20 13:28   ` [bug#58660] [PATCH 4/4] etc: teams: Display an id number zimoun
2022-11-05 12:18   ` [bug#58660] [PATCH 1/4] etc: teams: Improve scope display ( via Guix-patches via
2022-11-05 13:09     ` zimoun
2022-11-05 13:29       ` ( via Guix-patches via
2022-11-04 10:11 ` [bug#58660] [PATCH 0/4] Minor tweaks of etc/teams.scm zimoun
2022-11-09 16:23 ` Mathieu Othacehe
2022-11-17 20:27   ` zimoun
2022-11-18 17:31     ` Mathieu Othacehe
2022-11-17 20:28 ` [bug#58660] [PATCH v2 1/3] etc: teams: Add 'show' subcommand zimoun
2022-11-17 20:28   ` [bug#58660] [PATCH v2 2/3] etc: teams: Sort and itemize 'scope' field zimoun
2022-11-18 17:23     ` Mathieu Othacehe
2022-11-21 14:11       ` zimoun
2023-08-29 18:58         ` bug#58660: [PATCH 0/4] Minor tweaks of etc/teams.scm Maxim Cournoyer
2022-11-17 20:28   ` zimoun [this message]
2022-11-18 17:29   ` [bug#58660] [PATCH v2 1/3] etc: teams: Add 'show' subcommand Mathieu Othacehe
2022-11-21 16:00     ` zimoun

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=20221117202820.2054593-3-zimon.toutoune@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=58660@debbugs.gnu.org \
    --cc=othacehe@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).