Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Start cleaning up ghc-mod's Emacs frontend #325

Closed
wants to merge 14 commits into from
3 changes: 1 addition & 2 deletions Language/Haskell/GhcMod/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ customCradle wdir = do
cabalFile <- MaybeT $ findCabalFile wdir
let cabalDir = takeDirectory cabalFile
cradleFile <- MaybeT $ findCradleFile cabalDir
tmpDir <- liftIO $ newTempDir cabalDir
pkgDbStack <- liftIO $ parseCradle cradleFile
return Cradle {
cradleCurrentDir = wdir
, cradleRootDir = cabalDir
, cradleTempDir = tmpDir
, cradleTempDir = error "tmpDir"
, cradleCabalFile = Just cabalFile
, cradlePkgDbStack = pkgDbStack
}
Expand Down
9 changes: 6 additions & 3 deletions elisp/ghc-check.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
"Face used for marking hole lines."
:group 'ghc)

(defvar ghc-check-error-fringe (propertize "!" 'display '(left-fringe exclamation-mark)))
(defvar ghc-check-error-fringe
(propertize "!" 'display '(left-fringe exclamation-mark)))

(defvar ghc-check-warning-fringe (propertize "?" 'display '(left-fringe question-mark)))
(defvar ghc-check-warning-fringe
(propertize "?" 'display '(left-fringe question-mark)))

(defvar ghc-check-hole-fringe (propertize "_" 'display '(left-fringe horizontal-bar)))
(defvar ghc-check-hole-fringe
(propertize "_" 'display '(left-fringe horizontal-bar)))

(defvar ghc-display-error nil
"*An action to display errors/warnings for 'M-n' and 'M-p:
Expand Down
44 changes: 28 additions & 16 deletions elisp/ghc-comp.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
;;; ghc-comp.el
;;;

;; Author: Kazu Yamamoto <[email protected]>
;; Author: Kazu Yamamoto <[email protected]>, Daniel Gröber <[email protected]>
;; Created: Sep 25, 2009
;; Revised: Aug 16, 2014

;;; Code:

(require 'ghc-func)
(require 'ghc-rewrite)
(require 'ghc-process)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand Down Expand Up @@ -66,21 +68,24 @@ unloaded modules are loaded")

(defvar ghc-loaded-module nil)


(defvar ghc-mod-comp-syms '(ghc-module-names
ghc-language-extensions
ghc-option-flags
;; hard coded in GHCMod.hs
ghc-keyword-Prelude
ghc-keyword-Control.Applicative
ghc-keyword-Control.Exception
ghc-keyword-Control.Monad
ghc-keyword-Data.Char
ghc-keyword-Data.List
ghc-keyword-Data.Maybe
ghc-keyword-System.IO) )

(defun ghc-comp-init ()
(let* ((syms '(ghc-module-names
ghc-language-extensions
ghc-option-flags
;; hard coded in GHCMod.hs
ghc-keyword-Prelude
ghc-keyword-Control.Applicative
ghc-keyword-Control.Exception
ghc-keyword-Control.Monad
ghc-keyword-Data.Char
ghc-keyword-Data.List
ghc-keyword-Data.Maybe
ghc-keyword-System.IO))
(vals (ghc-boot (length syms))))
(ghc-set syms vals))
(let* ((vals (ghc-boot (length ghc-mod-comp-syms))))
(ghc-set ghc-mod-comp-syms vals))

(ghc-add ghc-module-names "qualified")
(ghc-add ghc-module-names "hiding")
;; hard coded in GHCMod.hs
Expand All @@ -91,7 +96,14 @@ unloaded modules are loaded")
"Data.Char"
"Data.List"
"Data.Maybe"
"System.IO")))
"System.IO"))
(ghc-import-module) )

(defun ghc-comp-deinit ()
(mapcar (lambda (s) (set s nil)) ghc-mod-comp-syms)
(setq ghc-loaded-module nil)
(setq ghc-merged-keyword nil) )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand Down
15 changes: 11 additions & 4 deletions elisp/ghc-info.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
;;; ghc-info.el
;;;

;; Author: Kazu Yamamoto <[email protected]>
;; Author: Kazu Yamamoto <[email protected]>, Daniel Gröber <[email protected]>
;; Created: Nov 15, 2010
;; Revised: Aug 16, 2014

;;; Code:

Expand All @@ -31,9 +32,8 @@
;;; type
;;;

(defvar ghc-type-overlay nil)

(make-variable-buffer-local 'ghc-type-overlay)
(defvar-local ghc-type-overlay nil "Overlay marking the extent of the
expression who's type was just analyzed.")

(defun ghc-type-set-ix (n)
(overlay-put ghc-type-overlay 'ix n))
Expand Down Expand Up @@ -63,6 +63,13 @@
(cons 'ghc-type-clear-overlay after-change-functions))
(add-hook 'post-command-hook 'ghc-type-post-command-hook))

(defun ghc-type-deinit ()
(remove-hook 'post-command-hook 'ghc-type-post-command-hook)
(setq after-change-functions
(delq 'ghc-type-clear-overlay after-change-functions))
;; TODO: remember buffers where overlays were created and clear them on deinit
(ghc-type-clear-overlay) )

(defun ghc-type-clear-overlay (&optional beg end len)
(when (overlayp ghc-type-overlay)
(ghc-type-set-ix 0)
Expand Down
Loading