I want to create a DSL in Elisp, looking something like this:
(install ;; do install ) (uninstall ;; do uninstall )
However, since Elisp has a global namespace, this is not a good idea. And the prefix of functions like this is so damn ugly.
(package-install ;; do install ) (package-uninstall ;; do uninstall )
So, I thought that the compromise of all commands could be wrapped in command calls as follows:
(commands (install ;; do install ) (uninstall ;; do uninstall ) ;; ... )
But since I donβt want to install and remove in the global namespace, I somehow have to replace all occurrences of commands in the command macros, perhaps, for example, prefix names, for example:
(defmacro commands (&rest body) (mapcar (lambda (exp) (setcar exp (intern (concat "package-" (symbol-name (car exp))))) (setcdr exp (list (cons 'progn (cdr exp))))) body) `(progn ,@body)) (commands (install ;; do install ) (uninstall ;; do uninstall ) ;; ... )
It looks like such a hack. Plus, this will not work if there are any nested commands.
Is there any good solution for this or a hack way?
Thanks!
macros emacs elisp
rejeep
source share