packages feed

ghc-mod 4.1.0 → 4.1.1

raw patch · 8 files changed

+97/−59 lines, 8 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Language/Haskell/GhcMod/Types.hs view
@@ -57,7 +57,11 @@  convert :: ToString a => Options -> a -> String convert opt@Options { outputStyle = LispStyle  } x = toLisp  opt x "\n"-convert opt@Options { outputStyle = PlainStyle } x = toPlain opt x "\n"+convert opt@Options { outputStyle = PlainStyle } x+  | str == "\n" = ""+  | otherwise   = str+  where+    str = toPlain opt x "\n"  class ToString a where     toLisp  :: Options -> a -> Builder
elisp/ghc-check.el view
@@ -80,9 +80,9 @@ 	      (buf ghc-process-original-buffer)) 	  (ghc-check-highlight-original-buffer file buf infos)))        (t-	(with-current-buffer ghc-process-original-buffer+	(ghc-with-current-buffer ghc-process-original-buffer 	  (remove-overlays (point-min) (point-max) 'ghc-check t))))-      (with-current-buffer ghc-process-original-buffer+      (ghc-with-current-buffer ghc-process-original-buffer 	(let ((len (length infos))) 	  (if (= len 0) 	      (setq mode-line-process "")@@ -91,7 +91,7 @@ 		   (wlen (- len elen))) 	      (setq mode-line-process (format " %d:%d" elen wlen))))))))    (t-    (with-current-buffer ghc-process-original-buffer+    (ghc-with-current-buffer ghc-process-original-buffer       (setq mode-line-process " failed")))))  (defun ghc-to-info (errs)@@ -114,7 +114,7 @@ 	    (ghc-add infos info)))))))  (defun ghc-check-highlight-original-buffer (ofile buf infos)-  (with-current-buffer buf+  (ghc-with-current-buffer buf     (remove-overlays (point-min) (point-max) 'ghc-check t)     (save-excursion       (goto-char (point-min))
elisp/ghc-func.el view
@@ -205,4 +205,12 @@ 	expr       (concat "(" expr ")")))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;++(defmacro ghc-with-current-buffer (buf &rest body)+  ;; (declare (indent 1))+  `(if (buffer-live-p ,buf)+       (with-current-buffer ,buf+	 ,@body)))+ (provide 'ghc-func)
elisp/ghc-process.el view
@@ -12,7 +12,8 @@  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar-local ghc-process-running nil)+(defvar ghc-process-running nil)+ (defvar-local ghc-process-process-name nil) (defvar-local ghc-process-original-buffer nil) (defvar-local ghc-process-original-file nil)@@ -29,27 +30,26 @@ (defun ghc-with-process (cmd callback &optional hook1 hook2)   (unless ghc-process-process-name     (setq ghc-process-process-name (ghc-get-project-root)))-  (when ghc-process-process-name+  (when (and ghc-process-process-name (not ghc-process-running))+    (setq ghc-process-running t)     (if hook1 (funcall hook1))     (let* ((cbuf (current-buffer)) 	   (name ghc-process-process-name) 	   (buf (get-buffer-create (concat " ghc-modi:" name))) 	   (file (buffer-file-name)) 	   (cpro (get-process name)))-      (with-current-buffer buf-	(unless ghc-process-running-	  (setq ghc-process-running t)-	  (setq ghc-process-original-buffer cbuf)-	  (setq ghc-process-original-file file)-	  (setq ghc-process-callback callback)-	  (setq ghc-process-hook hook2)-	  (erase-buffer)-	  (let ((pro (ghc-get-process cpro name buf)))-	    (process-send-string pro cmd)-	    (when ghc-debug-	      (ghc-with-debug-buffer-	       (insert (format "%% %s" cmd))))-	    pro))))))+      (ghc-with-current-buffer buf+        (setq ghc-process-original-buffer cbuf)+	(setq ghc-process-original-file file)+	(setq ghc-process-callback callback)+	(setq ghc-process-hook hook2)+	(erase-buffer)+	(let ((pro (ghc-get-process cpro name buf)))+	  (process-send-string pro cmd)+	  (when ghc-debug+	    (ghc-with-debug-buffer+	     (insert (format "%% %s" cmd))))+	  pro)))))  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -65,32 +65,39 @@ (defun ghc-start-process (name buf)   (let ((pro (start-file-process name buf ghc-interactive-command "-b" "\n" "-l")))     (set-process-filter pro 'ghc-process-filter)+    (set-process-sentinel pro 'ghc-process-sentinel)     (set-process-query-on-exit-flag pro nil)     pro))  (defun ghc-process-filter (process string)-  (with-current-buffer (process-buffer process)-    (goto-char (point-max))-    (insert string)-    (forward-line -1)-    (cond-     ((looking-at "^OK$")-      (if ghc-process-hook (funcall ghc-process-hook))-      (goto-char (point-min))-      (funcall ghc-process-callback 'ok)-      (when ghc-debug-	(let ((cbuf (current-buffer)))-	  (ghc-with-debug-buffer-	   (insert-buffer-substring cbuf))))-      (setq ghc-process-running nil))-     ((looking-at "^NG ")-      (funcall ghc-process-callback 'ng)-      (when ghc-debug-	(let ((cbuf (current-buffer)))-	  (ghc-with-debug-buffer-	   (insert-buffer-substring cbuf))))-      (setq ghc-process-running nil)))))+  (let ((pbuf (process-buffer process)))+    (if (not (get-buffer pbuf))+	(setq ghc-process-running nil) ;; just in case+      (ghc-with-current-buffer (process-buffer process)+        (goto-char (point-max))+	(insert string)+	(forward-line -1)+	(cond+	 ((looking-at "^OK$")+	  (if ghc-process-hook (funcall ghc-process-hook))+	  (goto-char (point-min))+	  (funcall ghc-process-callback 'ok)+	  (when ghc-debug+	    (let ((cbuf (current-buffer)))+	      (ghc-with-debug-buffer+	       (insert-buffer-substring cbuf))))+	  (setq ghc-process-running nil))+	 ((looking-at "^NG ")+	  (funcall ghc-process-callback 'ng)+	  (when ghc-debug+	    (let ((cbuf (current-buffer)))+	      (ghc-with-debug-buffer+	       (insert-buffer-substring cbuf))))+	  (setq ghc-process-running nil))))))) +(defun ghc-process-sentinel (process event)+  (setq ghc-process-running nil))+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  (defvar ghc-process-rendezvous nil)@@ -98,21 +105,21 @@ (defvar ghc-process-results nil)  (defun ghc-sync-process (cmd &optional n hook)-  (setq ghc-process-rendezvous nil)-  (setq ghc-process-results nil)-  (setq ghc-process-num-of-results (or n 1))-  (let ((pro (ghc-with-process cmd 'ghc-process-callback nil hook)))-    (condition-case nil-	(while (null ghc-process-rendezvous)-	  ;; 0.1 is too fast for Emacs 24.4.-	  ;; (sit-for 0.1 t) may get stuck when tooltip is displayed.-	  (sit-for 0.1)-	  ;; (discard-input) avoids getting stuck.-	  (discard-input))-      (quit-       (with-current-buffer (process-buffer pro)-	 (setq ghc-process-running nil)))))-  ghc-process-results)+  (unless ghc-process-running+    (setq ghc-process-rendezvous nil)+    (setq ghc-process-results nil)+    (setq ghc-process-num-of-results (or n 1))+    (let ((pro (ghc-with-process cmd 'ghc-process-callback nil hook)))+      (condition-case nil+	  (while (null ghc-process-rendezvous)+	    ;; 0.01 is too fast for Emacs 24.4.+	    ;; (sit-for 0.1 t) may get stuck when tooltip is displayed.+	    (sit-for 0.1)+	    ;; (discard-input) avoids getting stuck.+	    (discard-input))+	(quit+	 (setq ghc-process-running nil))))+    ghc-process-results))  (defun ghc-process-callback (status)   (cond
elisp/ghc.el view
@@ -20,7 +20,15 @@  ;;; Code: -(defconst ghc-version "4.1.0")+;; defvar-local was introduced in 24.3+(let* ((major 24)+       (minor 3))+  (if (or (< emacs-major-version major)+	  (and (= emacs-major-version major)+	       (< emacs-minor-version minor)))+      (error "ghc-mod requires at least Emacs %d.%d" major minor)))++(defconst ghc-version "4.1.1")  ;; (eval-when-compile ;;  (require 'haskell-mode))
ghc-mod.cabal view
@@ -1,5 +1,5 @@ Name:                   ghc-mod-Version:                4.1.0+Version:                4.1.1 Author:                 Kazu Yamamoto <kazu@iij.ad.jp> Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp> License:                BSD3
test/CheckSpec.hs view
@@ -34,3 +34,10 @@                 cradle <- findCradleWithoutSandbox                 res <- checkSyntax defaultOptions cradle ["Baz.hs"]                 res `shouldSatisfy` ("Baz.hs:5:1:Warning:" `isPrefixOf`)++        context "without errors" $ do+            it "doesn't output empty line" $ do+                withDirectory_ "test/data/ghc-mod-check/Data" $ do+                    cradle <- findCradleWithoutSandbox+                    res <- checkSyntax defaultOptions cradle ["Foo.hs"]+                    res `shouldBe` ""
test/LintSpec.hs view
@@ -10,3 +10,7 @@             res <- lintSyntax defaultOptions "test/data/hlint.hs"             res `shouldBe` "test/data/hlint.hs:4:8: Error: Redundant do\NULFound:\NUL  do putStrLn \"Hello, world!\"\NULWhy not:\NUL  putStrLn \"Hello, world!\"\n" +        context "without suggestions" $ do+            it "doesn't output empty line" $ do+                res <- lintSyntax defaultOptions "test/data/ghc-mod-check/Data/Foo.hs"+                res `shouldBe` ""