Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
incorporated nominolo's devel branch
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Sep 15, 2009
2 parents d270695 + 4fc1f14 commit 594de80
Show file tree
Hide file tree
Showing 15 changed files with 875 additions and 641 deletions.
File renamed without changes.
65 changes: 17 additions & 48 deletions emacs/scion.el
Expand Up @@ -1881,7 +1881,7 @@ If NO-POPUP is non-NIL, only show the buffer if it is already visible."
(let ((dir (or start-directory
default-directory
(error "No start directory given"))))
(if (car (directory-files dir t ".cabal$"))
(if (car (directory-files dir t ".+\.cabal$"))
dir
(let ((next-dir (file-name-directory (directory-file-name
(file-truename dir)))))
Expand All @@ -1892,7 +1892,7 @@ If NO-POPUP is non-NIL, only show the buffer if it is already visible."
"Return the only Cabal file in the given directory.
Returns NIL if the directory does not contain such file, and
signals an error if multiple files are present."
(let ((cabal-files (directory-files dir t ".cabal$")))
(let ((cabal-files (directory-files dir t ".+\.cabal$")))
(if (car cabal-files)
(if (cadr cabal-files)
(error "Multiple .cabal files in directory: %s" dir)
Expand Down Expand Up @@ -1954,16 +1954,6 @@ EXTRA-ARGS is a string of command line flags."
(setq scion-project-root-dir root-dir)
(message (format "Cabal project loaded: %s" x))))))

(defun scion-load-library ()
"Load the library of the current cabal project.
Sets the GHC flags for the library from the current Cabal project and loads it."
(interactive)
(message "Loading library...")
(scion-eval-async `(load-component :component (:library nil))
(lambda (result)
(scion-report-compilation-result result))))

(defun scion-count-notes (notes)
(let ((warns 0)
(errs 0))
Expand Down Expand Up @@ -2286,6 +2276,10 @@ forces it to be off. NIL toggles the current state."
(interactive)
(scion-eval '(dump-module-graph)))

(defun scion-dump-name-db ()
(interactive)
(scion-eval '(dump-name-db)))

(define-key scion-mode-map "\C-c\C-t" 'scion-thing-at-point)

(provide 'scion)
Expand All @@ -2300,32 +2294,7 @@ loaded."
(cond
((null comp)
(error "Invalid component"))

((scion-cabal-component-p comp)
(let* ((curr-cabal-file (scion-eval '(current-cabal-file)))
;; (current-component (scion-eval '(current-component))
(root-dir (scion-cabal-root-dir))
(new-cabal-file (ignore-errors (scion-cabal-file root-dir))))
;; if we have a component
(assert (not (null new-cabal-file)))
(if (equal curr-cabal-file new-cabal-file)
;; Same Cabal project, just load the component
(scion-load-component% comp)

;; Different Cabal project, we must configure it first.
(let ((rel-dist-dir (read-from-minibuffer "Dist directory: " ".dist-scion"))
(extra-args (read-from-minibuffer "Cabal Configure Flags: " "")))
(lexical-let ((root-dir root-dir)
(comp comp))
(scion-eval-async `(open-cabal-project :root-dir ,(expand-file-name root-dir)
:dist-dir ,rel-dist-dir
:extra-args ,extra-args)
(lambda (x)
(setq scion-project-root-dir root-dir)
(message (format "Cabal project loaded: %s" x))
(scion-load-component% comp))))))))

((eq (car comp) :file)
(t
(scion-load-component% comp))))

(defun scion-load-component% (comp)
Expand All @@ -2336,19 +2305,19 @@ loaded."

(defun scion-cabal-component-p (comp)
(cond
((eq (car comp) :library)
((plist-member comp :library)
t)
((and (consp comp)
(eq (car comp)
:executable))
((plist-member comp :executable)
t)
(t
nil)))

(defun scion-select-component ()
(let* ((cabal-dir (scion-cabal-root-dir))
(cabal-file (ignore-errors (scion-cabal-file cabal-dir)))
(cabal-components (ignore-errors (scion-cabal-components cabal-file)))
(cabal-components
(when cabal-file
(ignore-errors (scion-cabal-components cabal-file))))
(options (nconc cabal-components
`((:file ,(buffer-file-name))))))
(if (null (cdr options))
Expand All @@ -2366,12 +2335,12 @@ loaded."

(defun scion-format-component (comp)
(cond
((eq (car comp) :library)
((plist-member comp :library)
"Library")
((eq (car comp) :executable)
(format "Executable %s" (cadr comp)))
((eq (car comp) :file)
(format "File %s" (cadr comp)))
((plist-member comp :executable)
(format "Executable %s" (plist-get comp :executable)))
((plist-member comp :file)
(format "File %s" (plist-get comp :file)))
(t
(format "%s" comp))))

Expand Down
4 changes: 2 additions & 2 deletions lib/Scion.hs
Expand Up @@ -15,12 +15,12 @@ module Scion
, module Scion -- re-export full module at least for now
, module Scion.Session
, module Scion.Utils
, module Scion.Configure
, module Scion.Cabal
) where

import Scion.Types
import Scion.Session
import Scion.Configure
import Scion.Cabal
import Scion.Utils

import GHC
Expand Down

0 comments on commit 594de80

Please sign in to comment.