|
17 | 17 | (print x)
|
18 | 18 | x)
|
19 | 19 |
|
20 |
| -(define-macro (define-global first . rest) |
21 |
| - "(define-global var value) |
22 |
| - (define-global (name . args) body) |
23 |
| -
|
24 |
| - Macro that define functions or variables in global context, so they can be used |
25 |
| - inside let and get let variables in closure, Useful for universal macros." |
26 |
| - (if (pair? first) |
27 |
| - (let ((name (car first))) |
28 |
| - `(lips.env.set ,(symbol->string name) (lambda ,(cdr first) ,@rest))) |
29 |
| - `(lips.env.set ,(symbol->string first) ,(car rest)))) |
30 |
| - |
31 |
| -(define-macro (globalize expr . rest) |
32 |
| - "(globalize expr) |
33 |
| -
|
34 |
| - Macro will get the value of the expression and add each method as function to global |
35 |
| - scope." |
36 |
| - (let ((obj (eval expr (current-environment))) |
37 |
| - (make-name (if (pair? rest) |
38 |
| - (let ((pre (symbol->string (car rest)))) |
39 |
| - (lambda (name) (string->symbol (concat pre name)))) |
40 |
| - string->symbol))) |
41 |
| - `(begin |
42 |
| - ,@(filter pair? |
43 |
| - (map (lambda (key) |
44 |
| - (if (function? (. obj key)) |
45 |
| - (let* ((fname (gensym)) |
46 |
| - (args (gensym))) |
47 |
| - `(define-global (,(make-name key) . ,args) |
48 |
| - (apply (. ,expr ,key) ,args))))) |
49 |
| - (array->list (--> Object (keys obj)))))))) |
50 |
| - |
51 |
| - |
52 | 20 | ;; setup isomorphic-git and global fs methods as functions
|
53 | 21 | (define fs (let* ((fs (new LightningFS "fs"))
|
54 | 22 | (pfs fs.promises))
|
55 | 23 | (git.plugins.set "fs" fs)
|
56 | 24 | pfs))
|
57 | 25 |
|
58 |
| - |
59 |
| - |
60 | 26 | (define (new-repo dir)
|
61 | 27 | "Prepare new git repo with base app"
|
62 | 28 | (let ((dir (if (null? (match #/^\// dir)) (concat "/" dir) dir)))
|
|
86 | 52 | (console.log msg))))
|
87 | 53 | (console.log (concat "Registration succeeded. Scope is " req.scope)))
|
88 | 54 | (catch (e)
|
89 |
| - (console.log (concat "Registration failed " e))))) |
| 55 | + (console.log (concat "Registration failed " (repr e)))))) |
90 | 56 |
|
91 | 57 | (define refresh-editors (debounce (lambda ()
|
92 | 58 | (for-each (lambda (editor)
|
|
0 commit comments