Skip to content

Commit 7284a8d

Browse files
committed
init.scm: Use simpler re-export logic.
1 parent 6134e92 commit 7284a8d

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

guile/spotiqueue/init.scm

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,21 @@
2020
#:declarative? #f)
2121
(module-export-all! (current-module))
2222

23-
;; Syntax transformer to re-export all public defines from a given module from this module. Grabbed
24-
;; from https://www.mail-archive.com/bug-guile@gnu.org/msg10321.html
25-
;;
2623
;; What i want is, whenever someone imports (spotiqueue init), they should get whatever has been
2724
;; defined in (spotiqueue functions), too. The latter is the "phantom module" created in Swift-land
2825
;; when Spotiqueue boots, exporting a few functions which are needed to sensibly be able to interact
2926
;; with the music player.
30-
(define-syntax re-export-public-interface
31-
(syntax-rules ()
32-
"Re-export the public interface of a module or modules. Invoked as
33-
@code{(re-export-public-interface (mod1) (mod2) ...)}."
34-
((_ (m0 m0* ...) (mn mn* ...) ...)
35-
(let ((iface (module-public-interface (current-module))))
36-
(define (r-e-p-i module)
37-
(cond-expand
38-
(guile-3
39-
(module-for-each
40-
(lambda (sym val)
41-
(hashq-set! (module-replacements iface) sym #t)
42-
(module-add! iface sym val))
43-
(resolve-interface module)))
44-
(else
45-
(module-use! iface (resolve-interface module)))))
46-
(r-e-p-i '(m0 m0* ...))
47-
(r-e-p-i '(mn mn* ...))
48-
...))
49-
((_)
50-
(syntax-error "must provide one or more module names"))
51-
((_ m m* ...)
52-
(syntax-error "module names must look like lists"))))
53-
54-
(re-export-public-interface (spotiqueue functions))
55-
56-
;; The re-export thing should presumably be achievable with this snippet, from
57-
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47084, and it does seem to work, except that i feel
58-
;; like i can't really get my head around it. Notably i don't understand the docstring of
59-
;; `module-use!`, which simply states, "Add interface [the second arg] to the front of the use-list
60-
;; of module [the first arg]. Both arguments should be module objects, and interface should very
61-
;; likely be a module returned by resolve-interface." Also, (current-module) always resolves to
62-
;; (spotiqueue init), and not whatever is importing it...
6327
;;
64-
;; (eval-when (expand load eval)
65-
;; (module-use! (module-public-interface (current-module))
66-
;; (resolve-interface '(spotiqueue functions))))
28+
;; This snippet is from https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47084, and it does seem to
29+
;; work, except that i feel like i can't really get my head around it. Notably i don't understand
30+
;; the docstring of `module-use!`, which simply states, "Add interface [the second arg] to the front
31+
;; of the use-list of module [the first arg]. Both arguments should be module objects, and interface
32+
;; should very likely be a module returned by resolve-interface." Also, (current-module) always
33+
;; resolves to (spotiqueue init), and not whatever is importing it...
34+
35+
(eval-when (expand load eval)
36+
(module-use! (module-public-interface (current-module))
37+
(resolve-interface '(spotiqueue functions))))
6738

6839
(format #t "guile ~s: Loading Spotiqueue bootstrap config...~%" (module-name (current-module)))
6940

0 commit comments

Comments
 (0)