From c78274f7f69876a948293e35599a0b896d850c1f Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Sun, 24 Aug 2014 13:29:12 +0200 Subject: [PATCH 1/6] Try to fix each error only once --- elisp/ghc-check.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elisp/ghc-check.el b/elisp/ghc-check.el index 0998014..eafadfa 100644 --- a/elisp/ghc-check.el +++ b/elisp/ghc-check.el @@ -367,7 +367,7 @@ nil does not display errors/warnings. (defun ghc-check-insert-from-warning () (interactive) (let ((ret t)) - (dolist (data (mapcar (lambda (ovl) (overlay-get ovl 'ghc-msg)) (ghc-check-overlay-at (point))) ret) + (dolist (data (delete-dups (mapcar (lambda (ovl) (overlay-get ovl 'ghc-msg)) (ghc-check-overlay-at (point)))) ret) (save-excursion (cond ((string-match "Inferred type: \\|no type signature:" data) From 6cad2b5e908060ac6e3ecc729fc9e3c7d96b6867 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sat, 23 Aug 2014 20:47:15 -0500 Subject: [PATCH 2/6] Use advice to check syntax on save-buffer --- elisp/ghc.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/elisp/ghc.el b/elisp/ghc.el index c541301..9700204 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -64,7 +64,6 @@ (defvar ghc-sort-key "\es") (defvar ghc-type-key "\C-c\C-t") (defvar ghc-info-key "\C-c\C-i") -(defvar ghc-check-key "\C-x\C-s") (defvar ghc-toggle-key "\C-c\C-c") (defvar ghc-jump-key "\C-c\C-j") (defvar ghc-module-key "\C-c\C-m") @@ -103,7 +102,6 @@ (define-key haskell-mode-map ghc-help-key 'ghc-display-errors) (define-key haskell-mode-map ghc-insert-key 'ghc-insert-template) (define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines) - (define-key haskell-mode-map ghc-check-key 'ghc-save-buffer) (define-key haskell-mode-map ghc-toggle-key 'ghc-toggle-check-command) (define-key haskell-mode-map ghc-jump-key 'ghc-jump-file) (define-key haskell-mode-map ghc-module-key 'ghc-insert-module) @@ -118,7 +116,10 @@ (define-key haskell-mode-map ghc-prev-hole-key 'ghc-goto-prev-hole) (define-key haskell-mode-map ghc-next-hole-key 'ghc-goto-next-hole) (ghc-comp-init) - (setq ghc-initialized t)) + (setq ghc-initialized t) + (defadvice save-buffer (after ghc-check-syntax-on-save activate) + "Check syntax with GHC when a haskell-mode buffer is saved." + (when (eq 'haskell-mode major-mode) (ghc-check-syntax)))) (ghc-import-module) (ghc-check-syntax)) From f194b528c82cbbc458761c9fe850ad401888bfd7 Mon Sep 17 00:00:00 2001 From: Ruben Astudillo Date: Sat, 23 Aug 2014 04:00:40 -0400 Subject: [PATCH 3/6] browseIt with modified environment to solve #265 --- src/GHCModi.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GHCModi.hs b/src/GHCModi.hs index 36d2696..d14de7f 100644 --- a/src/GHCModi.hs +++ b/src/GHCModi.hs @@ -316,5 +316,11 @@ browseIt :: IOish m -> ModuleString -> GhcModT m (String, Bool, Set FilePath) browseIt set mdl = do - ret <- browse mdl + let (det,rest') = break (== ' ') mdl + rest = dropWhile (== ' ') rest' + ret <- if det == "-d" + then withOptions setDetailed (browse rest) + else browse mdl return (ret, True, set) + where + setDetailed opt = opt { detailed = True } From 510ca3d3b65fe980078b9943f3f8183887766dec Mon Sep 17 00:00:00 2001 From: randen Date: Mon, 25 Aug 2014 17:19:17 -0700 Subject: [PATCH 4/6] Don't turn C-u into a prefix command * elisp/ghc.el * There are many ways to fix issue #351 so this is just one example and may not fit the style you prefer, so please feel free to use or not. It is easy to work-around the issue by setting ghc-initial-sig-key to another key combination before ghc-init, but it would be nice to have a fix. The use of C-u for this binding seems to be just as a flag, thus this change takes the simplest fix to achieve that purpose. --- elisp/ghc.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/elisp/ghc.el b/elisp/ghc.el index 9700204..a54d586 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -73,7 +73,6 @@ (defvar ghc-shallower-key "\C-c<") (defvar ghc-deeper-key "\C-c>") ;(defvar ghc-case-split-key "\C-c\C-s") -(defvar ghc-initial-sig-key "\C-u\et") (defvar ghc-refine-key "\C-c\C-f") (defvar ghc-auto-key "\C-c\C-a") (defvar ghc-prev-hole-key "\C-c\ep") @@ -100,7 +99,7 @@ (define-key haskell-mode-map ghc-previous-key 'ghc-goto-prev-error) (define-key haskell-mode-map ghc-next-key 'ghc-goto-next-error) (define-key haskell-mode-map ghc-help-key 'ghc-display-errors) - (define-key haskell-mode-map ghc-insert-key 'ghc-insert-template) + (define-key haskell-mode-map ghc-insert-key 'ghc-insert-template-or-signature) (define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines) (define-key haskell-mode-map ghc-toggle-key 'ghc-toggle-check-command) (define-key haskell-mode-map ghc-jump-key 'ghc-jump-file) @@ -110,7 +109,6 @@ (define-key haskell-mode-map ghc-shallower-key 'ghc-make-indent-shallower) (define-key haskell-mode-map ghc-deeper-key 'ghc-make-indent-deeper) ;(define-key haskell-mode-map ghc-case-split-key 'ghc-case-split) - (define-key haskell-mode-map ghc-initial-sig-key 'ghc-initial-code-from-signature) (define-key haskell-mode-map ghc-refine-key 'ghc-refine) (define-key haskell-mode-map ghc-auto-key 'ghc-auto) (define-key haskell-mode-map ghc-prev-hole-key 'ghc-goto-prev-hole) @@ -153,4 +151,10 @@ (insert "\nEnvironment variables:\n") (insert (format "\tPATH=%s\n" path)))) +(defun ghc-insert-template-or-signature (&optional flag) + (interactive "P") + (if flag + (ghc-initial-code-from-signature) + (ghc-insert-template))) + (provide 'ghc) From b728294d3d2eb2836594ea0442b4c39410c6aed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 29 Aug 2014 19:27:22 +0200 Subject: [PATCH 5/6] Bump version to 5.0.1.2 --- ChangeLog | 7 +++++++ elisp/ghc.el | 2 +- ghc-mod.cabal | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e372862..2cd4c93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-08-29 v5.0.1.2 + * Merge #345, Try fixing duplicate errors + * Merge #344, elisp: Use advice to check syntax on save-buffer + * Merge #341, support `browse -d` in ghc-modi + * Merge #352, elisp: Fix C-u accidentally getting turned into a + prefix command + 2014-08-24 v5.0.1.1 * Fix CaseSplitting faliure when using "fancy types" (see #336) * Print error information in "spec" test suite when using `extract` diff --git a/elisp/ghc.el b/elisp/ghc.el index a54d586..17ee84a 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -28,7 +28,7 @@ (< emacs-minor-version minor))) (error "ghc-mod requires at least Emacs %d.%d" major minor))) -(defconst ghc-version "5.0.0") +(defconst ghc-version "5.0.1.2") ;; (eval-when-compile ;; (require 'haskell-mode)) diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 70b374e..31ac7b2 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -1,5 +1,5 @@ Name: ghc-mod -Version: 5.0.1.1 +Version: 5.0.1.2 Author: Kazu Yamamoto Daniel Gröber Alejandro Serrano From 615c6c4543ea5bb884c5a7b003b76f9ecd3d0f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 12 Sep 2014 03:48:22 +0200 Subject: [PATCH 6/6] Workaround for #340 --- Language/Haskell/GhcMod/Target.hs | 14 +++++++++----- test/CheckSpec.hs | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Language/Haskell/GhcMod/Target.hs b/Language/Haskell/GhcMod/Target.hs index 1744a72..51d64e4 100644 --- a/Language/Haskell/GhcMod/Target.hs +++ b/Language/Haskell/GhcMod/Target.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} module Language.Haskell.GhcMod.Target ( setTargetFiles ) where @@ -5,7 +6,7 @@ module Language.Haskell.GhcMod.Target ( import Control.Applicative ((<$>)) import Control.Monad (forM, void, (>=>)) import DynFlags (ExtensionFlag(..), xopt) -import GHC (DynFlags(..), LoadHowMuch(..)) +import GHC (LoadHowMuch(..)) import qualified GHC as G import Language.Haskell.GhcMod.DynFlags import Language.Haskell.GhcMod.Monad @@ -50,7 +51,10 @@ setTargetFiles files = do setCompilerMode Intelligent needsFallback :: G.ModuleGraph -> Bool -needsFallback = any (hasTHorQQ . G.ms_hspp_opts) - where - hasTHorQQ :: DynFlags -> Bool - hasTHorQQ dflags = any (`xopt` dflags) [Opt_TemplateHaskell, Opt_QuasiQuotes] +needsFallback = any $ \ms -> + let df = G.ms_hspp_opts ms in + Opt_TemplateHaskell `xopt` df + || Opt_QuasiQuotes `xopt` df +#if __GLASGOW_HASKELL__ >= 708 + || (Opt_PatternSynonyms `xopt` df) +#endif diff --git a/test/CheckSpec.hs b/test/CheckSpec.hs index c492701..7c704a4 100644 --- a/test/CheckSpec.hs +++ b/test/CheckSpec.hs @@ -31,6 +31,11 @@ spec = do res <- runID $ checkSyntax ["Baz.hs"] res `shouldSatisfy` ("Baz.hs:5:1:Warning:" `isPrefixOf`) + it "works with modules using PatternSynonyms" $ do + withDirectory_ "test/data/pattern-synonyms" $ do + res <- runID $ checkSyntax ["B.hs"] + res `shouldSatisfy` ("B.hs:6:9:Warning:" `isPrefixOf`) + it "works with foreign exports" $ do withDirectory_ "test/data" $ do res <- runID $ checkSyntax ["ForeignExport.hs"]