all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 43627@debbugs.gnu.org, Leo Prikler <leo.prikler@student.tugraz.at>
Subject: [bug#43627] [PATCH core-updates v2 1/2] guix: Add an append-separator? field to the <search-path-specification> record.
Date: Sat, 10 Apr 2021 22:42:18 +0200	[thread overview]
Message-ID: <87o8el27o5.fsf@gnu.org> (raw)
In-Reply-To: <20210330155102.16610-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Tue, 30 Mar 2021 11:51:01 -0400")

Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> This new field allows to specify in a search-path-specification that a
> trailing separator should be added to the computed value of the environment
> variable.  A trailing separator sometimes has the meaning that the usual
> builtin locations should be looked up as well as the ones explicitly
> specified.
>
> One use case is to specify the Emacs library paths using EMACSLOADPATH.  This
> allows to not embed the Emacs version in its search path specification, which
> has been shown to cause issues when upgrading a profile or when defining
> variant Emacs packages of different versions.

Got it now.  :-)

Leo\x19s patch series seems to be addressing the same issue:

  https://issues.guix.gnu.org/47661

Should we hold on until we\x19ve reviewed and acted upon #47661?  Or does
it have known uses apart from Emacs?

> * guix/search-paths.scm (searh-path-specification): Add an APPEND-SEPARATOR?
> field.
> (search-path-specification->sexp): Adjust accordingly.
> (sexp->search-path-specification): Likewise.
> (evaluate-search-paths): Append a separator to the search path value when both
> `separator' and `append-separator?' are #t.  Document the new behavior.
> * guix/scripts/environment.scm (create-environment): Adjust the logic used to
> merge search-path values when creating an environment profile.
> * guix/build/gnu-build-system.scm (set-paths): Adjust accordingly.

Overall LGTM.  I\x19d suggest maybe replacing \x18append-separator?\x19 by
\x18trailing-separator?\x19, which I find a bit clearer.

Could you add a test or two in tests/search-paths.scm, for the corner
cases?

> -             ((env-var (files ...) separator type pattern)
> +             ((env-var (files ...) separator type pattern append-sep)
>                (set-path-environment-variable env-var files
>                                               input-directories
>                                               #:separator separator
>                                               #:type type
> -                                             #:pattern pattern)))
> +                                             #:pattern pattern
> +                                             #:append-separator? append-sep)))
>              search-paths)
>  
>    (when native-search-paths
>      ;; Search paths for native inputs, when cross building.
>      (for-each (match-lambda
> -               ((env-var (files ...) separator type pattern)
> +               ((env-var (files ...) separator type pattern append-sep)
>                  (set-path-environment-variable env-var files

I\x19d fully spell out the variable name, like \x18append-separator?\x19,
\x18append?\x19, \x18trailing?\x19, as per our coding style.

> +++ b/guix/build/profiles.scm
> @@ -1,5 +1,6 @@
>  ;;; GNU Guix --- Functional package management for GNU
>  ;;; Copyright © 2015, 2017, 2018, 2019, 2020, 2021 Ludovic Court¨s <ludo@gnu.org>
> +;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -20,6 +21,7 @@
>    #:use-module (guix build union)
>    #:use-module (guix build utils)
>    #:use-module (guix search-paths)
> +  #:use-module (srfi srfi-1)
>    #:use-module (srfi srfi-26)
>    #:use-module (ice-9 ftw)
>    #:use-module (ice-9 match)
> @@ -51,10 +53,13 @@ user-friendly name of the profile is, for instance ~/.guix-profile rather than
>           ((? string? separator)
>            (let ((items (string-tokenize* value separator)))
>              (cons search-path
> -                  (string-join (map (lambda (str)
> -                                      (string-append replacement (crop str)))
> -                                    items)
> -                               separator)))))))))
> +                  (string-join
> +                   (map (lambda (str)
> +                          (string-append replacement (crop str)))
> +                        ;; When APPEND-SEPARATOR? is #t, the trailing
> +                        ;; separator causes an empty string item.  Remove it.
> +                        (remove string-null? items))
> +                   separator)))))))))

If we remove the empty string, don\x19t we lose the trailing separator?

> +++ b/guix/build/utils.scm
> @@ -573,7 +573,8 @@ for under the directories designated by FILES.  For example:
>                                          #:key
>                                          (separator ":")
>                                          (type 'directory)
> -                                        pattern)
> +                                        pattern
> +                                        (append-separator? #f))
>    "Look for each of FILES of the given TYPE (a symbol as returned by
>  'stat:type') in INPUT-DIRS.  Set ENV-VAR to a SEPARATOR-separated path
>  accordingly.  Example:
> @@ -590,11 +591,16 @@ denoting file names to look for under the directories designated by FILES:
>                                   (list docbook-xml docbook-xsl)
>                                   #:type 'regular
>                                   #:pattern \"^catalog\\\\.xml$\")
> -"
> +
> +When both SEPARATOR and APPEND-SEPARATOR? are true, a separator is appended to
> +the value of the environment variable."
>    (let* ((path  (search-path-as-list files input-dirs
>                                       #:type type
>                                       #:pattern pattern))
> -         (value (list->search-path-as-string path separator)))
> +         (value (list->search-path-as-string path separator))
> +         (value (if append-separator?
> +                          (string-append value separator)
> +                          value)))

Indentation is off.

That\x19s it.  Thanks and apologies for the delay!

Ludo\x19.




  parent reply	other threads:[~2021-04-10 20:43 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-26  6:11 [bug#43627] [PATCH core-updates]: Add a 'append-separator?' field to the <search-path-specification> record Maxim Cournoyer
2020-09-26  6:14 ` [bug#43627] [PATCH core-updates 1/3] guix: Add an append-separator? " Maxim Cournoyer
2020-09-26  6:14   ` [bug#43627] [PATCH core-updates 2/3] gnu: emacs: Use the new append-separator? option to define its search path Maxim Cournoyer
2020-09-26  6:14   ` [bug#43627] [PATCH core-updates 3/3] Revert "emacs-build-system: Ensure the core libraries appear last in the load path." Maxim Cournoyer
2020-09-27 19:01 ` [bug#43627] [PATCH core-updates]: Add a 'append-separator?' field to the <search-path-specification> record Ludovic Courtès
2020-10-03 21:22   ` Maxim Cournoyer
2020-11-02 13:59     ` Ludovic Courtès
2020-11-08  5:49       ` Maxim Cournoyer
2021-03-30 15:51 ` [bug#43627] [PATCH core-updates v2 1/2] guix: Add an append-separator? " Maxim Cournoyer
2021-03-30 15:51   ` [bug#43627] [PATCH core-updates v2 2/2] gnu: emacs: Use the new append-separator? option to define its search path Maxim Cournoyer
2021-04-10 20:42   ` Ludovic Courtès [this message]
2021-05-20 14:24     ` bug#43627: [PATCH core-updates v2 1/2] guix: Add an append-separator? field to the <search-path-specification> record Maxim Cournoyer
2021-03-30 18:41 ` [bug#43627] [PATCH] gnu: emacs: Wrap EMACSLOADPATH Leo Prikler
2021-04-04  4:35   ` bug#47458: Terrible UX upgrading Emacs in Guix Maxim Cournoyer
2021-04-04  7:49     ` Leo Prikler
2021-04-06 12:09       ` Maxim Cournoyer
2021-04-06 15:49         ` Leo Prikler
2021-04-07 19:46           ` Maxim Cournoyer
2021-05-20 13:24             ` Maxim Cournoyer
  -- strict thread matches above, loose matches on Subject: below --
2021-03-29  2:02 Mark H Weaver
2021-03-29  8:07 ` Leo Prikler
2021-03-29  8:24   ` Maxime Devos
2021-03-29  8:43     ` Leo Prikler
2021-03-29 15:55 ` [bug#45359] " Ludovic Courtès
2021-03-29 15:55 ` Ludovic Courtès
2021-03-29 18:25   ` bug#45359: " Maxim Cournoyer
2020-12-22  3:28     ` [bug#45359] [PATCH]: Re-introduce Emacs packages specific installation prefix Maxim Cournoyer
2020-12-22  8:51       ` bug#45316: " Leo Prikler
2020-12-22 18:09         ` Maxim Cournoyer
2020-12-22 19:10           ` Leo Prikler
2020-12-26  5:01             ` Maxim Cournoyer
2020-12-26 10:56               ` Leo Prikler
2020-12-27  4:44                 ` Maxim Cournoyer
2020-12-27  8:46                   ` Leo Prikler
     [not found]       ` <handler.45359.D45359.161704236132600.notifdone@debbugs.gnu.org>
2021-03-29 18:45         ` [bug#45359] closed (Re: bug#47458: Terrible UX upgrading Emacs in Guix) Maxim Cournoyer
2021-03-29 18:48         ` bug#45359: [PATCH]: Re-introduce Emacs packages specific installation prefix Maxim Cournoyer
2021-03-30  8:04     ` [bug#45359] bug#47458: Terrible UX upgrading Emacs in Guix 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8el27o5.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=43627@debbugs.gnu.org \
    --cc=leo.prikler@student.tugraz.at \
    --cc=maxim.cournoyer@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.