             (set-buffer-menubar current-menubar)
             (add-submenu nil fsharp-mode-xemacs-menu))))
 
+  (setq compile-command (fsharp-choose-compile-command (buffer-file-name)))
   (turn-on-fsharp-doc-mode)
-
   (run-hooks 'fsharp-mode-hook)
 
   (if fsharp-smart-indentation

      ;; fsharp-indent-offset.  Never turn it on, because the user must
      ;; have explicitly turned it off.
      (if (/= tab-width fsharp-indent-offset)
          (setq indent-tabs-mode nil))
      )))

(defun fsharp-set-compile-command ()
  "Hook to set compile-command locally, unless there is a Makefile in the
   current directory."
  (interactive)
  (unless (or (null buffer-file-name)
              (file-exists-p "makefile")
              (file-exists-p "Makefile"))
    (let* ((filename (file-name-nondirectory buffer-file-name))
           (basename (file-name-sans-extension filename))
           (command nil))
      (cond
       ((string-match ".*\\.fs\$" filename)
        (setq command fsharp-compiler) ; (concat "fsc -o " basename)
        )
       ((string-match ".*\\.fsl\$" filename) ;FIXME
        (setq command "fslex"))
       ((string-match ".*\\.fsy\$" filename) ;FIXME
        (setq command "fsyacc"))
       )
      (if command
          (progn
            (make-local-variable 'compile-command)
            (setq compile-command (concat command " " filename))))
      )))

(add-hook 'fsharp-mode-hook 'fsharp-set-compile-command)

(defun fsharp-find-alternate-file ()
  (interactive)

      (define-key map [eval-phrase] '("Eval phrase" . fsharp-eval-phrase))
      )))

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.fs[iylx]?$" . fsharp-mode))

