On 2025-02-20 20:46, Arun Isaac wrote:

> Hi Nicolas,
>
> How about the following?
>
> (save-module-excursion
>  (lambda ()
>    (set-current-module (resolve-module '(guix scripts pull)))
>    (your-code-here)))

Hi Arun, thanks for your answer, doesn't seem to help though.

This snippet displays %options of (guix scripts pull):
(eval
 `(begin
    (reload-module (current-module))
    (display %options))
 (resolve-module '(guix scripts pull) #:ensure #f))

This one doesn't:
(save-module-excursion
  (lambda ()
    (set-current-module (resolve-module '(guix scripts pull)))
    (reload-module (current-module))
    (display %options)))

But I guess at this point they almost have the same length/readability
already.  Maybe I could create an eval-in-module macro that only takes a
module and a "thunk" to make that more readable and not having to check
the end of a big function to understand how undefined variables are set.

"thunk" here is not really one since it is quoted code for future
evaluation, rather than real code.

WDYT? Is there a better solution?

-- 
Best regards,
Nicolas Graves

Reply via email to