Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*print-meta* in CIDER macroexpansions #1090

Closed
tsdh opened this issue Apr 29, 2015 · 5 comments
Closed

*print-meta* in CIDER macroexpansions #1090

tsdh opened this issue Apr 29, 2015 · 5 comments
Assignees

Comments

@tsdh
Copy link
Contributor

tsdh commented Apr 29, 2015

Although I have (set! *print-meta* true) at the REPL, when I do C-c RET on some macro form, the resulting *cider-macroexpansion*'s contents are not printed with their metadata.

This breaks debugging macroexpansion for me. I have macros that expand to code containing other macro calls, and I pass essential data from the outer macros to the inner macros using metadata. The expansion works correct in clojure, but I can't do it stepwise for debugging purposes in CIDER because the metadata isn't printed in the *cider-macroexpansion* buffer, and so expanding a macro in the expansion won't work.

Here is a minimal example that demonstrates the issue:

(in-ns 'user)

(defmacro defun-1 [name args & code]
  (when-not (:foo (meta name))
    (throw (RuntimeException. "No metadata")))
  `(defn ~name ~args ~@code))

(defmacro defun [name args & code]
  `(defun-1 ~(with-meta name {:foo true}) ~args ~@code))

(defun plus-1 [x]
  (inc x))

(plus-1 7)

Compiling the buffer prints 8, so the macroexpansion in Clojure works just fine. However, when you expand the (defun plus-1...) with CIDER, you cannot expand the resulting (defun-1 plus-1...) form anymore because the :foo metadata which defun attaches to the symbol plus-1 is gone (not printed).

So I'd be very happy with some customization option for enabling printing of metadata with CIDER macroexpansion. Alternatively, it could also just honor the *print-meta* value in the REPL.

@cichli
Copy link
Member

cichli commented Apr 29, 2015

Using the value set in the REPL definitely makes sense. For now, does using alter-var-root instead of set! work around the problem?

(alter-var-root #'*print-meta* (constantly true))

@tsdh
Copy link
Contributor Author

tsdh commented Apr 29, 2015

No, sadly not.

@cichli cichli self-assigned this Apr 29, 2015
@cichli
Copy link
Member

cichli commented Apr 29, 2015

Thanks for testing - I'll sort this out this evening.

@cichli cichli closed this as completed in f713020 Apr 29, 2015
@cichli
Copy link
Member

cichli commented Apr 29, 2015

@tsdh I've added the cider-macroexpansion-print-metadata option; setting that to true will cause the metadata to be printed. You might need a lein -U deps to grab the latest cider-nrepl if your lein has already checked today.

@tsdh
Copy link
Contributor Author

tsdh commented Apr 30, 2015

@cichli Thanks, works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants