From a483f4f8b6dea19369aefec2d238e940ef651ba9 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Tue, 19 Aug 2014 14:56:01 +0900 Subject: [PATCH] error messages are stored after NG, not printed in stderr. --- Language/Haskell/GhcMod/Utils.hs | 7 +++---- elisp/ghc-check.el | 2 +- elisp/ghc-func.el | 11 +++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Language/Haskell/GhcMod/Utils.hs b/Language/Haskell/GhcMod/Utils.hs index 37a33b1..2047681 100644 --- a/Language/Haskell/GhcMod/Utils.hs +++ b/Language/Haskell/GhcMod/Utils.hs @@ -1,14 +1,13 @@ module Language.Haskell.GhcMod.Utils where -import MonadUtils (MonadIO, liftIO) import Control.Exception import Control.Monad.Error (MonadError(..), Error(..)) +import MonadUtils (MonadIO, liftIO) import System.Directory (getCurrentDirectory, setCurrentDirectory) -import System.Process (readProcessWithExitCode) import System.Exit (ExitCode(..)) -import System.IO (hPutStrLn, stderr) import System.IO.Error (tryIOError) +import System.Process (readProcessWithExitCode) -- dropWhileEnd is not provided prior to base 4.5.0.0. dropWhileEnd :: (a -> Bool) -> [a] -> [a] @@ -34,9 +33,9 @@ readProcess' cmd opts = do (rv,output,err) <- liftIO $ readProcessWithExitCode cmd opts "" case rv of ExitFailure val -> do - liftIO $ hPutStrLn stderr err throwError $ strMsg $ cmd ++ " " ++ unwords opts ++ " (exit " ++ show val ++ ")" + ++ "\n" ++ err ExitSuccess -> return output diff --git a/elisp/ghc-check.el b/elisp/ghc-check.el index 8cf9282..65566b7 100644 --- a/elisp/ghc-check.el +++ b/elisp/ghc-check.el @@ -110,7 +110,7 @@ nil does not display errors/warnings. (setq mode-line-process (format " %d:%d" elen wlen))))) (force-mode-line-update)))) (t - (let* ((err (buffer-substring-no-properties (point-min) (point))) + (let* ((err (ghc-unescape-string (buffer-substring-no-properties (+ (point) 3) (point-max)))) (info (ghc-make-hilit-info :file "Fail errors:" :line 0 diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index a55273b..97f749b 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -32,6 +32,17 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun ghc-unescape-string (str) + (with-temp-buffer + (insert str) + (goto-char (point-min)) + (while (search-forward "\\n" nil t) (replace-match "\n" nil t)) + (goto-char (point-min)) + (while (search-forward "\\\\" nil t) (replace-match "\\" nil t)) + (buffer-substring-no-properties (point-min) (point-max)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defmacro ghc-add (sym val) `(setq ,sym (cons ,val ,sym)))