Function: edebug-match-specs
edebug-match-specs is a byte-compiled function defined in
edebug.el.gz.
Signature
(edebug-match-specs CURSOR SPECS REMAINDER-HANDLER)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/edebug.el.gz
(defun edebug-match-specs (cursor specs remainder-handler)
;; Append results of matching the list of specs.
;; The first spec is handled and the remainder-handler handles the rest.
(let ((edebug-matching-depth
(if (> edebug-matching-depth edebug-max-depth)
(error "Too deep - perhaps infinite loop in spec?")
(1+ edebug-matching-depth))))
(cond
((null specs) nil)
;; Is the spec dotted?
((atom specs)
(let ((edebug-dotted-spec t));; Containing spec list was dotted.
(edebug-match-specs cursor (list specs) remainder-handler)))
;; The reason for processing here &optional, &rest, and vectors
;; which might contain them even when the form is dotted is to
;; allow them to match nothing, so we can advance to the dotted
;; part of the spec.
((or (listp (edebug-cursor-expressions cursor))
(vectorp (car specs))
(memq (car specs) '(&optional &rest))) ; Process normally.
;; (message "%scursor=%s specs=%s"
;; (make-string edebug-matching-depth ?|) cursor (car specs))
(let* ((spec (car specs))
(rest)
(first-char (and (symbolp spec) (aref (symbol-name spec) 0)))
(match (cond
((eq ?& first-char);; "&" symbols take all following specs.
(edebug--match-&-spec-op spec cursor (cdr specs)))
((eq ?: first-char);; ":" symbols take one following spec.
(setq rest (cdr (cdr specs)))
(edebug--handle-:-spec-op spec cursor (car (cdr specs))))
(t;; Any other normal spec.
(setq rest (cdr specs))
(edebug-match-one-spec cursor spec)))))
;; The first match result may not be a list, which can happen
;; when matching the tail of a dotted list. In that case
;; there is no remainder.
(if (listp match)
(nconc match
(funcall remainder-handler cursor rest remainder-handler))
match)))
;; Must be a dotted form, with no remaining &rest or &optional specs to
;; match.
(t
(if (not edebug-dotted-spec)
(edebug-no-match cursor "Dotted spec required."))
;; Cancel dotted spec and dotted form.
(let ((edebug-dotted-spec)
(this-form (edebug-cursor-expressions cursor))
(this-offset (edebug-cursor-offsets cursor)))
;; Wrap the form in a list, by changing the cursor.
(edebug-set-cursor cursor (list this-form) this-offset)
;; Process normally, then unwrap the result.
(car (edebug-match-specs cursor specs remainder-handler)))))))