Malabarba / names

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

Problem with the namespace references when wrapped in macro calls. #31

Open ahungry opened 6 years ago

ahungry commented 6 years ago
         (eval-when-compile (require 'names))

         ;;;###autoload                                                                                                                                                  
         (define-namespace names-test-

         (defvar -a 5 "The names-test--a variable.")

         (defmacro freeze-ui (&rest body)
           "Basically, lock up the UI, then run BODY."
           `(save-excursion
              (save-restriction
                (save-window-excursion
                  ,@body))))

         (defun print-a ()
           (interactive)
           (freeze-ui (print -a)))

         )

Results in:

Symbol’s value as variable is void: -a

I saw the note about quoted/unquoted, however in this sample, it's the body being passed to the defmacro that is failing to evaluate.

Is there a workaround for this scenario? So that I do not have to do (print names-test--a) in the print-a defun? (this is a minimalist example for a real use case I'm hitting).

Malabarba commented 6 years ago

In order for Names to correctly namespace inside macro calls, the macro needs to be defined with a debug spec. In your case I think it will suffice to add (declare (debug body)) immediately after the docstring. But you should read up on defining macro debug specs for edebug.