help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I debug a macro?


From: Alan Schmitt
Subject: Re: How can I debug a macro?
Date: Wed, 16 Dec 2015 14:21:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

On 2015-12-16 10:43, phillip.lord@russet.org.uk (Phillip Lord) writes:

> If you want to debug a *usage* of the macro, then the macro itself needs
> to declare to edebug how it should be evaled. In most cases this is
> quite easy. For `org-babel-comint-with-output' it's slightly tricker
> because AFAICT the `meta' argument is not evaluated.

I want to debug the usage of the macro. It returns the wrong value and
I want to understand why.

> Consider these:
>
> (defmacro temp-m (one &rest body)
>   (declare (debug (form body)))
>   (let ((a one))
>     `(progn ,@body)))
>
> (defun h ()
>   (temp-m
>    '(1 2 3)
>    (message "hello")))
>
> with the "declare" form in temp-m, calling "h" will step through the
> code in "h" as you expect. The debug sexp means "first argument is a
> form, the rest are body elements which need stepping through".
>
> So, I think evalling:
>
> (def-edebug-spec org-babel-comint-with-output
>   (form body))
>
> should do the trick, although probably you want to send a patch in for
> org-comint.el (using the declare version) so that it works for everyone.

I'm trying this, but I'm confused at to what I need to do after I add
the declare form.

This is what I tried:
- add the declare form to org-babel-comint-with-output
- C-u C-M-x on org-babel-comint-with-output
- evaluate a block in org-mode

I then see a message:
edebug: Symbol's value as variable is void: edebug-def-mark

I then tried to debug the function calling the macro:
- C-u C-M-x on org-babel-execute:ocaml
- strangely, a debugging start even though I have not called the
function yet (I have not evaluated the source block)
- I try stepping through the macro, and it makes no sense (I see a lot
of things like "Result: (edebug-after (edebug-before 17) 20 (session
(edebug-after 0 18 org-babel-ocaml-eoe-output) t (edebug-after 0 19
full-body)))")
- if I then try to run a code block, I can start to step through
org-babel-execute:ocaml as expected, but as soon as I reach the point
where the macro is to be evaluated, I get an error: "Symbol's value as
variable is void: edebug-after"

I feel like I'm missing something here. Am I using this correctly?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Athmospheric CO₂ (Updated December 13, 2015, Mauna Loa Obs.): 401.31 ppm

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]