Function: ad-set-arguments
ad-set-arguments is a byte-compiled function defined in advice.el.gz.
Signature
(ad-set-arguments ARGLIST INDEX VALUES-FORM)
Documentation
Make form to assign elements of VALUES-FORM as actual ARGLIST args.
The assignment starts at position INDEX.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
(defun ad-set-arguments (arglist index values-form)
"Make form to assign elements of VALUES-FORM as actual ARGLIST args.
The assignment starts at position INDEX."
(let ((values-index 0)
argument-access set-forms)
(while (setq argument-access (ad-access-argument arglist index))
(push (if (symbolp argument-access)
(ad-set-argument
arglist index
(ad-element-access values-index 'ad-vAlUeS))
(setq arglist nil) ;; Terminate loop.
(if (= (car argument-access) 0)
`(setq
,(car (cdr argument-access))
,(ad-list-access values-index 'ad-vAlUeS))
`(setcdr
,(ad-list-access (1- (car argument-access))
(car (cdr argument-access)))
,(ad-list-access values-index 'ad-vAlUeS))))
set-forms)
(setq index (1+ index))
(setq values-index (1+ values-index)))
(if (null set-forms)
(error "ad-set-arguments: No argument at position %d of `%s'"
index arglist)
(if (= (length set-forms) 1)
;; For exactly one set-form we can use values-form directly,...
(ad-substitute-tree
(lambda (form) (eq form 'ad-vAlUeS))
(lambda (_form) values-form)
(car set-forms))
;; ...if we have more we have to bind it to a variable:
`(let ((ad-vAlUeS ,values-form))
,@(reverse set-forms)
;; work around the old backquote bug:
,'ad-vAlUeS)))))