 	    (push (cadr f) locals)))
 	(geiser-syntax--scan-locals bfs sbfs
 				    (car (last (or rest names)))
-				    partial
                                     (1- nesting)
 				    locals)))))
 

	((null form) nil)
	(t (cons (car form) (geiser-syntax--linearize (cdr form))))))

(defun geiser-syntax--scan-locals (bfs sbfs form partial nesting locals)
  (if (or (null form) (not (listp form)))
      (geiser-syntax--normalize locals)
    (if (not (geiser-syntax--binding-form-p bfs sbfs (car form)))
	(geiser-syntax--scan-locals bfs sbfs
				    (car (last form))
                                    partial (1- nesting) locals)
      (let* ((head (car form))
	     (name (geiser-syntax--if-symbol (cadr form)))
	     (names (if name (geiser-syntax--if-list (caddr form))

                       (geiser-syntax--binding-form-p bfs sbfs (car names))))
	     (rest (if (and name (not bns)) (cdddr form) (cddr form)))
	     (use-names (and (or rest
                                 (< nesting 1)
                                 (geiser-syntax--binding-form*-p sbfs head))
                             (not bns))))
	(when name (push name locals))
        (when (geiser-syntax--symbol-eq head 'case-lambda)
          (dolist (n (and (> nesting 0) (caar (last form))))
            (when n (push n locals)))
          (setq rest (and (> nesting 0) (cdr form)))
          (setq use-names nil))
        (when (geiser-syntax--symbol-eq head 'syntax-rules)
          (dolist (n (and (> nesting 0) (cdaar (last form))))
            (when n (push n locals)))
          (setq rest (and (> nesting 0) (cdr form))))
	(when use-names
	  (dolist (n (geiser-syntax--linearize names))
            (let ((xs (if (and (listp n) (listp (car n))) (car n) (list n))))
              (dolist (x xs) (when x (push x locals))))))
	(dolist (f (butlast rest))
	  (when (and (listp f)
                     (geiser-syntax--symbol-eq (car f) 'define)
