Function: ad-substitute-tree
ad-substitute-tree is a byte-compiled function defined in
advice.el.gz.
Signature
(ad-substitute-tree SUBTREE-TEST FUNCTION TREE)
Documentation
Substitute qualifying subTREEs with result of FUNCTION(subTREE).
Only proper subtrees are considered, for example, if TREE is (1 (2 (3)) 4) then the subtrees will be 1 (2 (3)) 2 (3) 3 4, dotted structures are allowed too. Once a qualifying subtree has been found its subtrees will not be considered anymore. (ad-substitute-tree 'atom 'identity tree) generates a copy of TREE.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
;; @@ Some utilities:
;; ==================
;; We don't want the local arguments to interfere with anything
;; referenced in the supplied functions => the cryptic casing:
(defun ad-substitute-tree (sUbTrEe-TeSt fUnCtIoN tReE)
"Substitute qualifying subTREEs with result of FUNCTION(subTREE).
Only proper subtrees are considered, for example, if TREE is (1 (2 (3)) 4)
then the subtrees will be 1 (2 (3)) 2 (3) 3 4, dotted structures are
allowed too. Once a qualifying subtree has been found its subtrees will
not be considered anymore. (ad-substitute-tree \\='atom \\='identity tree)
generates a copy of TREE."
(cond ((consp tReE)
(cons (if (funcall sUbTrEe-TeSt (car tReE))
(funcall fUnCtIoN (car tReE))
(if (consp (car tReE))
(ad-substitute-tree sUbTrEe-TeSt fUnCtIoN (car tReE))
(car tReE)))
(ad-substitute-tree sUbTrEe-TeSt fUnCtIoN (cdr tReE))))
((funcall sUbTrEe-TeSt tReE)
(funcall fUnCtIoN tReE))
(t tReE)))