Function: elint-form

elint-form is a byte-compiled function defined in elint.el.gz.

Signature

(elint-form FORM ENV &optional NOHANDLER)

Documentation

Lint FORM in the environment ENV.

Optional argument NOHANDLER non-nil means ignore elint-special-forms. Returns the environment created by the form.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/elint.el.gz
(defun elint-form (form env &optional nohandler)
  "Lint FORM in the environment ENV.
Optional argument NOHANDLER non-nil means ignore `elint-special-forms'.
Returns the environment created by the form."
  (cond
   ((consp form)
    (let ((func (cdr (assq (car form) elint-special-forms))))
      (if (and func (not nohandler))
	  ;; Special form
	  (funcall func form env)

	(let* ((func (car form))
	       (args (elint-get-args func env))
	       (argsok t))
	  (cond
	   ((eq args 'undefined)
	    (setq argsok nil)
	    (or (memq 'undefined-functions elint-ignored-warnings)
		(elint-error "Call to undefined function: %s" func)))

	   ((eq args 'unknown) nil)

	   (t (setq argsok (elint-match-args form args))))

	  ;; Is this a macro?
	  (if (elint-env-macrop env func)
	      ;; Macro defined in buffer, expand it
	      (if argsok
		  ;; FIXME error if macro uses macro, eg bytecomp.el.
		  (condition-case nil
		      (elint-form
		       (macroexpand form (elint-env-macro-env env)) env)
		    (error
		     (or (memq 'macro-expansion elint-ignored-warnings)
			 (elint-error "Elint failed to expand macro: %s" func))
		     env))
		env)

	    (let ((fcode (if (symbolp func)
			     (if (fboundp func)
				 (indirect-function func))
			   func)))
	      (if (and (listp fcode) (eq (car fcode) 'macro))
		  ;; Macro defined outside buffer
		  (if argsok
		      (elint-form (macroexpand form) env)
		    env)
		;; Function, lint its parameters
		(elint-forms (cdr form) env))))))))
   ((symbolp form)
    ;; :foo variables are quoted
    (and (/= (aref (symbol-name form) 0) ?:)
	 (not (memq 'unbound-reference elint-ignored-warnings))
	 (elint-unbound-variable form env)
	 (elint-warning "Reference to unbound symbol: %s" form))
    env)

   (t env)))