 
 ;;user customizable variables
 
-(require 'fsharp-mode-indent)
+(namespace fsharp-mode
+  :export
+  [find-sln-or-fsproj])
 
 (defvar fsharp-mode-version 0.7
   "Version of this fsharp-mode")
 
-(defvar fsharp-compiler "fsc"
-  "Program name for compiling a F# file")
+;;; Compilation
+
+(defvar fsharp-compile-command
+  (or (executable-find "fsharpc")
+      (executable-find "fsc"))
+  "The program used to compile F# source files.")
+
+(defvar fsharp-build-command
+  (or (executable-find "xbuild")
+      (executable-find "msbuild"))
+  "The command used to build F# projects and solutions.")
+
+(defvar fsharp-compiler nil
+  "The command used to compile an individual F# buffer.
+This will be set to a sane default, depending the type of file
+and whether it is in a project directory.")
+(make-variable-buffer-local 'fsharp-compiler)
+
+;;; ----------------------------------------------------------------------------
 
 (defvar fsharp-shell-active nil
   "Non nil when a subshell is running.")

      ;; 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)

  (require 'inf-fsharp-mode)
  (inferior-fsharp-show-subshell))

(defconst fsharp-error-regexp-fs
  "^\\([^(\n]+\\)(\\([0-9]+\\),\\([0-9]+\\)):"
  "Regular expression matching the error messages produced by fsc.")
