From: itd <itd@net.in.tum.de>
To: 58250@debbugs.gnu.org
Subject: bug#58250: [PATCH 1/2] modules: Remove load path prefix from module name.
Date: Sun, 02 Oct 2022 16:35:33 +0200 [thread overview]
Message-ID: <87y1tye1je.fsf@localhost> (raw)
In-Reply-To: <handler.58250.B.16647208196976.ack@debbugs.gnu.org>
* guix/modules.scm (file-name->module-name): Ignore load path prefix
when building module name.
---
It was mentioned on IRC, that (guix modules)'s file-name->module-name
might be function to be used by the JSON importer (and fixed if needed).
This patch attempts to implement the idea from the bug report.
guix/modules.scm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/guix/modules.scm b/guix/modules.scm
index 61bc8e1978..269d52ae1e 100644
--- a/guix/modules.scm
+++ b/guix/modules.scm
@@ -100,11 +100,23 @@ (define module-file-dependencies
'()))))))
(define file-name->module-name
- (let ((not-slash (char-set-complement (char-set #\/))))
+ (let ((not-slash (char-set-complement (char-set #\/)))
+ (load-path-prefix-length
+ (lambda (file)
+ ;; Length of the longest prefix among all given load paths.
+ (apply max (map
+ (lambda (path) (if (string-prefix? path file)
+ (string-length path)
+ 0))
+ %load-path)))))
(lambda (file)
"Return the module name (a list of symbols) corresponding to FILE."
(map string->symbol
- (string-tokenize (string-drop-right file 4) not-slash)))))
+ (string-tokenize
+ (string-drop
+ (string-drop-right file 4)
+ (load-path-prefix-length file))
+ not-slash)))))
(define (module-name->file-name module)
"Return the file name for MODULE."
base-commit: ae221813745783ef1b7eee47561a2208cd5ad512
--
2.37.3
next prev parent reply other threads:[~2022-10-02 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 14:26 bug#58250: guix import json: GUIX_PACKAGE_PATH -- no code for module itd
[not found] ` <handler.58250.B.16647208196976.ack@debbugs.gnu.org>
2022-10-02 14:35 ` itd [this message]
2022-12-23 13:49 ` Ludovic Courtès
2022-10-02 14:38 ` bug#58250: [PATCH 2/2] import: print: Use file-name->module-name itd
2022-12-23 13:50 ` bug#58250: guix import json: GUIX_PACKAGE_PATH -- no code for module 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=87y1tye1je.fsf@localhost \
--to=itd@net.in.tum.de \
--cc=58250@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 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.