(defun import-grep ()
  (interactive "*")
  (setq default-case-fold-search nil)
  (goto-char 0)
  (insert "(setq file-list\n'(\"")
  (replace-string "\n" "\"\n\"")
  (kill-line 0)
  (insert "))\n")
  (not-modified)
  (eval-current-buffer nil)
  (while (not (equal file-list nil))
    (usage-grep (car file-list) "MACHINE")
    (setq file-list (cdr file-list))
    )
  (switch-to-buffer "MACHINE.usage")
  (write-file "MACHINE.usage")
  )

(defun usage-grep (file target-module)
  (interactive "fFile name: \nsTarget module: ")
  (find-file file)
  (goto-char 0)
  (if (search-forward (concat "FROM " target-module " IMPORT") nil t)
      (progn (setq buffer-read-only nil)
	     (re-search-forward "[,;]")
	     (forward-word -1)
	     (delete-region (point-min) (point))
	     (search-forward ";")
	     (delete-region (1- (point)) (point-max))
	     (goto-char 0)
	     (replace-regexp "^#.*" "")
	     (goto-char 0)
	     (replace-regexp "[, \t\n][, \t\n]*" " ")
	     (goto-char 0)
	     (insert (file-name-nondirectory file) " : ")
	     (goto-char (point-max))
	     (insert "\n")
	     (set-buffer-modified-p nil)
	     (append-to-buffer "MACHINE.usage" (point-min) (point-max))
	     )
    )
  )
