Malabarba / names

A Namespace implementation for Emacs-Lisp
250 stars 19 forks source link

Support for `cl-defun` -- A Workaround #32

Open alhassy opened 4 years ago

alhassy commented 4 years ago

There seems to be no support for cl-defun; which is unfortunate.


The expected approach does not namespace a cl-defun-ed function:

(define-namespace woah-
(cl-defun here ())
)
;; ⇒ here

Temporarily rebinding cl-defun to defun may make things work ... so far, I have been unable to get macrolet or anything else to make this work; the reason may be that I'm macroletting defun to rewrite into cl-defun, which uses defun in its definition?

What I've been able to do thus far is to locally treat defun as producing symbolic lists that begin with cl-defun, but define-namespaces only sees the defun and so rewrites them beforehand and the resulting fragements are then eval-uated.

 (eval (cl-macrolet ((defun (&rest more) `(cons 'cl-defun (quote ,more))))

   (define-namespace woah-
   (list 'progn

   (defun first  (x &key (y 3)) (+ x y))
   (defun second (x &key (y 3)) (+ x y))

   )))) ;; ⇒ woah-first and woah-second are defined

Any alternative approach would be appreciated!