As I write progressively more ambitious macros I find my (declare (debug specs))
more involved. There're times where I really wish I could step debug the spec matching itself, or at least perform the match on some form given a spec. Looks like Edebug has all the required parts in place, but it is so stateful that I keep running into errors where some flag or index is set to the wrong thing, etc. I just can't figure out all the wrapping I need to do to match some form against the speclist I supply. This is as far as I've gotten:
(defun match-debug-spec (form specs)
(with-temp-buffer
(insert (format "%S" form))
(goto-char (point-min))
(let* (edebug-offsets
(cursor (edebug-new-cursor
(list (edebug-read-storing-offsets (current-buffer)))
(list edebug-offsets))))
(edebug-match cursor specs))))
(match-debug-spec
'(funcall (lambda (a b &rest args) (list* a b args)) 1 2 3 4)
'(&rest form))
This is where I get (void-variable edebug-offset-index)
error. I tinkered a lot, but I run into something every time. Doesn't help that the implementation isn't exactly documented. I have to guess at what cursors
are and all the magic it performs while instrumenting code. Can anyone give pointers?
Someone spec'ed the entire CL
package and I refuse to believe they managed to convince the spec matcher just by trial and error. How do I do it systematically?