geiser-mode-switch-to-repl-and-enter does not work for pseudo-modules
Hi,
When using C-c C-a or geiser-mode-switch-to-repl-and-enter to quickly open and jump to a REPL attached to the current file, it creates an environment that lacks even the (guile) module when the edited file is a pseudo-module, i.e. a module which does not exist in the file hierarchy of the project.
This is commonly used in the GNU Guix test suite and some other places. Case at hand: the https://codeberg.org/guix/guix/src/branch/master/gnu/packages/ld-wrapper.in file, which defines a module like:
(define-module (gnu build-support ld-wrapper)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:autoload (ice-9 rdelim) (read-delimited)
#:export (ld-wrapper))
If you open such a "module" in Geiser, and execute C-c C-a, the attached REPL you are left with an empty environment where you can't even use pk, define or anything else:
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,m (gnu build-support ld-wrapper)
scheme@(gnu build-support ld-wrapper)> (pk 2)
;;; <stdin>:18:1: warning: possibly unbound variable `pk'
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: pk
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(gnu build-support ld-wrapper) [1]> ,a define
When I experimented with ways to test that script, I could load the file and access the pseudo-module like:
(load "gnu/packages/ld-wrapper.in")
(define ld-wrapper-module (resolve-module '(gnu build-support ld-wrapper)))
(define library-files-linked (module-ref ld-wrapper-module 'library-files-linked))
So it looks like despite the file not existing on disk, there's something that can be done to make it available/expose its internals.
Thank you for Geiser!