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)
    (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))))

 '(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?

  • I played in that code years ago, but it's too fuzzy now, sorry. Please send patches via M-x report-emacs-bug adding comments to the code (those can be either things you discovered, or questions about the code). You might also want to discuss this (even as a monologue showing your progress and set backs) on emacs-devel where you may have more luck finding people knowledgeable and interested in this.
    – Stefan
    Dec 12, 2018 at 15:22


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.