Function: helpful--callees-1
helpful--callees-1 is a byte-compiled function defined in helpful.el.
Signature
(helpful--callees-1 FORM)
Documentation
Return a list of all the functions called in FORM.
Assumes FORM has been macro expanded. The returned list may contain duplicates.
Source Code
;; Defined in ~/.emacs.d/elpa/helpful-20250408.334/helpful.el
(defun helpful--callees-1 (form)
"Return a list of all the functions called in FORM.
Assumes FORM has been macro expanded. The returned list
may contain duplicates."
(cond
((not (consp form))
nil)
;; See `(elisp)Special Forms'. For these special forms, we recurse
;; just like functions but ignore the car.
((memq (car form) '(and catch defconst defvar if interactive
or prog1 prog2 progn save-current-buffer
save-restriction setq setq-default
track-mouse unwind-protect while))
(-flatten
(-map #'helpful--callees-1 (cdr form))))
((eq (car form) 'cond)
(let* ((clauses (cdr form))
(clause-fns
;; Each clause is a list of forms.
(--map
(-map #'helpful--callees-1 it) clauses)))
(-flatten clause-fns)))
((eq (car form) 'condition-case)
(let* ((protected-form (nth 2 form))
(protected-form-fns (helpful--callees-1 protected-form))
(handlers (-drop 3 form))
(handler-bodies (-map #'cdr handlers))
(handler-fns
(--map
(-map #'helpful--callees-1 it) handler-bodies)))
(append
protected-form-fns
(-flatten handler-fns))))
;; Calling a function with a well known higher order function, for
;; example (funcall 'foo 1 2).
((and
(memq (car form) '(funcall apply call-interactively
mapcar mapc mapconcat -map))
(eq (car-safe (nth 1 form)) 'quote))
(cons
(cadr (nth 1 form))
(-flatten
(-map #'helpful--callees-1 (cdr form)))))
((eq (car form) 'function)
(let ((arg (nth 1 form)))
(if (symbolp arg)
;; #'foo, which is the same as (function foo), is a function
;; reference.
(list arg)
;; Handle (function (lambda ...)).
(helpful--callees-1 arg))))
((eq (car form) 'lambda)
;; Only consider the body, not the param list.
(-flatten (-map #'helpful--callees-1 (-drop 2 form))))
((eq (car form) 'closure)
;; Same as lambda, but has an additional argument of the
;; closed-over variables.
(-flatten (-map #'helpful--callees-1 (-drop 3 form))))
((memq (car form) '(let let*))
;; Extract function calls used to set the let-bound variables.
(let* ((var-vals (-second-item form))
(var-val-callees
(--map
(if (consp it)
(-map #'helpful--callees-1 it)
nil)
var-vals)))
(append
(-flatten var-val-callees)
;; Function calls in the let body.
(-map #'helpful--callees-1 (-drop 2 form)))))
((eq (car form) 'quote)
nil)
(t
(cons
(car form)
(-flatten
(-map #'helpful--callees-1 (cdr form)))))))