Function: elint-check-conditional-form
elint-check-conditional-form is a byte-compiled function defined in
elint.el.gz.
Signature
(elint-check-conditional-form FORM ENV)
Documentation
Check the when/unless/and/or FORM in ENV.
Does basic handling of featurep tests.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/elint.el.gz
;; For the featurep parts, an alternative is to have
;; elint-get-top-forms skip the irrelevant branches.
(defun elint-check-conditional-form (form env)
"Check the when/unless/and/or FORM in ENV.
Does basic handling of `featurep' tests."
(let ((func (car form))
(test (cadr form)))
;; Misses things like (and t (featurep 'xemacs))
;; Check byte-compile-maybe-guarded.
(cond ((and (memq func '(when and))
(eq (car-safe test) 'boundp)
(= 2 (length test))
(eq (car-safe (cadr test)) 'quote))
;; Cf elint-check-let-form, which modifies the whole ENV.
(let ((elint-bound-variable (cadr (cadr test))))
(elint-form form env t)))
((and (memq func '(when and))
(eq (car-safe test) 'fboundp)
(= 2 (length test))
(eq (car-safe (cadr test)) 'quote))
(let ((elint-bound-function (cadr (cadr test))))
(elint-form form env t)))
;; Let's not worry about (if (not (boundp...
((and (eq func 'if)
(eq (car-safe test) 'boundp)
(= 2 (length test))
(eq (car-safe (cadr test)) 'quote))
(let ((elint-bound-variable (cadr (cadr test))))
(elint-form (nth 2 form) env))
(dolist (f (nthcdr 3 form))
(elint-form f env)))
((and (eq func 'if)
(eq (car-safe test) 'fboundp)
(= 2 (length test))
(eq (car-safe (cadr test)) 'quote))
(let ((elint-bound-function (cadr (cadr test))))
(elint-form (nth 2 form) env))
(dolist (f (nthcdr 3 form))
(elint-form f env)))
((and (memq func '(when and)) ; skip all
(or (null test)
(member test '((featurep (quote xemacs))
(not (featurep (quote emacs)))))
(and (eq (car-safe test) 'and)
(equal (car-safe (cdr test))
'(featurep (quote xemacs)))))))
((and (memq func '(unless or))
(equal test '(featurep (quote emacs)))))
((and (eq func 'if)
(or (null test)
(member test '((featurep (quote xemacs))
(not (featurep (quote emacs)))))
(and (eq (car-safe test) 'and)
(equal (car-safe (cdr test))
'(featurep (quote xemacs))))))
(dolist (f (nthcdr 3 form))
(elint-form f env))) ; lint the else branch
((and (eq func 'if)
(equal test '(featurep (quote emacs))))
(elint-form (nth 2 form) env)) ; lint the if branch
;; Process conditional as normal, without handler.
(t
(elint-form form env t))))
env)