Function: macroexp--posify-form-1

macroexp--posify-form-1 is a byte-compiled function defined in macroexp.el.gz.

Signature

(macroexp--posify-form-1 FORM CALL-POS DEPTH)

Documentation

The recursive part of macroexp--posify-form.

It modifies a single symbol to a symbol with position, or does nothing. FORM and CALL-POS are as in that function. DEPTH is a small integer, decremented at each recursive call, to prevent infinite recursion.

Return the form with a symbol with position in the canonical position for that form, either the one that was already there or CALL-POS; return nil if this isn't possible.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/macroexp.el.gz
(defun macroexp--posify-form-1 (form call-pos depth)
  "The recursive part of `macroexp--posify-form'.
It modifies a single symbol to a symbol with position, or does nothing.
FORM and CALL-POS are as in that function.  DEPTH is a small integer,
decremented at each recursive call, to prevent infinite recursion.

Return the form with a symbol with position in the canonical position
for that form, either the one that was already there or CALL-POS; return
nil if this isn't possible.
"
  (let (new-form)
    (cond
     ((zerop depth) nil)
     ((and (consp form)
           (symbolp (car form))
           (car form))
      (unless (symbol-with-pos-p (car form))
        (setcar form (position-symbol (car form) call-pos)))
      form)
     ((consp form)
      (or (when (setq new-form (macroexp--posify-form-1
                                (car form) call-pos (1- depth)))
            (setcar form new-form)
            form)
          (when (setq new-form (macroexp--posify-form-1
                                (cdr form) call-pos (1- depth)))
            (setcdr form new-form)
            form)))
     ((symbolp form)
      (if form                          ; Don't position nil!
          (if (symbol-with-pos-p form)
              form
            (position-symbol form call-pos))))
     ((and (or (vectorp form) (recordp form)))
      (let ((len (length form))
            (i 0)
            )
        (while (and (< i len)
                    (not (setq new-form (macroexp--posify-form-1
                                         (aref form i) call-pos (1- depth)))))
          (setq i (1+ i)))
        (when (< i len)
          (aset form i new-form)
          form))))))