|
20 | 20 | #:declarative? #f)
|
21 | 21 | (module-export-all! (current-module))
|
22 | 22 |
|
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 |
| -;; |
26 | 23 | ;; What i want is, whenever someone imports (spotiqueue init), they should get whatever has been
|
27 | 24 | ;; defined in (spotiqueue functions), too. The latter is the "phantom module" created in Swift-land
|
28 | 25 | ;; when Spotiqueue boots, exporting a few functions which are needed to sensibly be able to interact
|
29 | 26 | ;; 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... |
63 | 27 | ;;
|
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)))) |
67 | 38 |
|
68 | 39 | (format #t "guile ~s: Loading Spotiqueue bootstrap config...~%" (module-name (current-module)))
|
69 | 40 |
|
|
0 commit comments