Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defpackage :program (:use #:cl #:cl-who #:parenscript))
- (in-package :program)
- (setq *js-string-delimiter* #\")
- (defmacro emit (language file &body body)
- `(with-open-file (str ,file
- :direction :output
- :if-exists :supersede)
- (princ ,(cond ((eq language 'html)
- `(with-html-output-to-string (s nil :prologue t :indent t) ,@body))
- ((eq language 'javascript)
- `(ps ,@body))
- ((eq language 'json)
- `(remove #\; (ps ,@body))))
- str)))
- (emit json "~/file.json"
- (create "name" "Wiki-Links"
- "description" "Organize your Wikipedia reading history.")
- (create "version" 1
- "permissions" (array "storage")))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; macro-expansion form that the code produces:
- ;;
- ;; (WITH-OPEN-FILE (STR "~/file.json" :DIRECTION :OUTPUT :IF-EXISTS :SUPERSEDE)
- ;; (PRINC
- ;; (REMOVE #\;
- ;; (PS
- ;; (CREATE "name" "Wiki-Links" "description"
- ;; "Organize your Wikipedia reading history.")
- ;; (CREATE "version" 1 "permissions" (ARRAY "storage"))))
- ;; STR))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement