From: Attila Lendvai <attila@lendvai.name>
To: "55464@debbugs.gnu.org" <55464@debbugs.gnu.org>
Subject: bug#55464: alternative way
Date: Tue, 17 May 2022 00:09:03 +0000 [thread overview]
Message-ID: <d88ruR0MIQx5-PtTF8RaHdg15TJ3ItvylaHxhkm4cAMZp_AhKjAZmtYFC6u-X0zaInJLgOcmor783ZQiNRwhzLTeBFU8VVEMMPcvv7n0zwE=@lendvai.name> (raw)
In-Reply-To: <625DOHHScuzJjNNfdQOqaLqGWVTmXC-S9PcF2xU3nzsFYG4XYTSEt0NGXDSXnBqVHqYqr6AsEbTysg7y_fxoqeBkbEtCqMZrx9muo3DlvS0=@lendvai.name>
as Ludovic kindly pointed out on IRC, i can use this instead:
(module-filename (current-module))
unfortunately, this returns a relative path, which is only useful using (search-path %load-path ...), which introduces some uncertainty about what actually gets loaded depending on the runtime value of %load-path... :|
therefore, i decided to read the file at macroexpand-time. after some struggle with hygienic macros:
(define-syntax read-module-relative-file
(lambda (syn)
(syntax-case syn ()
((_ filename)
(with-syntax
;; Read the file at compile time and macroexpand to the first form.
((form (%read-module-relative-file (current-module)
(syntax->datum #'filename))))
#''form)))))
(define (%read-module-relative-file module filename)
(with-input-from-file
(or (search-path %load-path
(string-append (dirname (module-filename module))
"/" filename))
(error "%read-module-relative-file failed for" filename))
read))
not beautiful, but works.
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“It is just as difficult and dangerous to try to free a people that wants to remain servile as it is to enslave a people that wants to remain free.”
— Niccolò Machiavelli (1469–1527)
next prev parent reply other threads:[~2022-05-17 0:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 21:04 bug#55464: (current-filename) is #f when guix pull'ing Attila Lendvai
2022-05-17 0:09 ` Attila Lendvai [this message]
2022-05-18 9:14 ` Ludovic Courtès
2022-05-19 13:32 ` Attila Lendvai
2022-05-21 16:39 ` 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
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='d88ruR0MIQx5-PtTF8RaHdg15TJ3ItvylaHxhkm4cAMZp_AhKjAZmtYFC6u-X0zaInJLgOcmor783ZQiNRwhzLTeBFU8VVEMMPcvv7n0zwE=@lendvai.name' \
--to=attila@lendvai.name \
--cc=55464@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 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).