From 1c61a8d50a40d44d6567fe0e867983a2201cb8cf Mon Sep 17 00:00:00 2001 From: Vasantha Ganesh K Date: Mon, 28 Aug 2017 00:20:36 +0530 Subject: [PATCH 1/4] revample Compilation with haskell --- haskell-compile.el | 74 ++++++-------------- haskell-mode-test-dir31102pMV/Main.hs | 1 + haskell-mode-test-dir31102pMV/README.md | 1 + haskell-mode-test-dir31102pMV/abc.cabal | 1 + haskell-mode-test-dir31102pMV/cabal.project | 1 + haskell-mode-test-dir31102pMV/src/moduleA.hs | 1 + haskell-mode-test-dir31102pMV/src/moduleB.hs | 1 + haskell-mode-test-dir31102pMV/tests/test1.hs | 1 + haskell-mode-test-dir31102pMV/tests/test2.hs | 1 + haskell-mode-test-dir31574aOV/Main.hs | 1 + haskell-mode-test-dir31574aOV/README.md | 1 + haskell-mode-test-dir31574aOV/abc.cabal | 1 + haskell-mode-test-dir31574aOV/cabal.project | 1 + haskell-mode-test-dir31574aOV/src/moduleA.hs | 1 + haskell-mode-test-dir31574aOV/src/moduleB.hs | 1 + haskell-mode-test-dir31574aOV/tests/test1.hs | 1 + haskell-mode-test-dir31574aOV/tests/test2.hs | 1 + haskell-utils.el | 7 ++ tests/haskell-compile-tests.el | 50 +++++++++++++ tests/sample-code/does_not_work.hs | 10 +++ tests/sample-code/fibonoacci.hs | 10 +++ 21 files changed, 114 insertions(+), 53 deletions(-) create mode 100644 haskell-mode-test-dir31102pMV/Main.hs create mode 100644 haskell-mode-test-dir31102pMV/README.md create mode 100644 haskell-mode-test-dir31102pMV/abc.cabal create mode 100644 haskell-mode-test-dir31102pMV/cabal.project create mode 100644 haskell-mode-test-dir31102pMV/src/moduleA.hs create mode 100644 haskell-mode-test-dir31102pMV/src/moduleB.hs create mode 100644 haskell-mode-test-dir31102pMV/tests/test1.hs create mode 100644 haskell-mode-test-dir31102pMV/tests/test2.hs create mode 100644 haskell-mode-test-dir31574aOV/Main.hs create mode 100644 haskell-mode-test-dir31574aOV/README.md create mode 100644 haskell-mode-test-dir31574aOV/abc.cabal create mode 100644 haskell-mode-test-dir31574aOV/cabal.project create mode 100644 haskell-mode-test-dir31574aOV/src/moduleA.hs create mode 100644 haskell-mode-test-dir31574aOV/src/moduleB.hs create mode 100644 haskell-mode-test-dir31574aOV/tests/test1.hs create mode 100644 haskell-mode-test-dir31574aOV/tests/test2.hs create mode 100644 tests/haskell-compile-tests.el create mode 100644 tests/sample-code/does_not_work.hs create mode 100644 tests/sample-code/fibonoacci.hs diff --git a/haskell-compile.el b/haskell-compile.el index 2f4224032..9241edcad 100644 --- a/haskell-compile.el +++ b/haskell-compile.el @@ -1,6 +1,7 @@ ;;; haskell-compile.el --- Haskell/GHC compilation sub-mode -*- lexical-binding: t -*- ;; Copyright (C) 2013 Herbert Valerio Riedel +;; Copyright (C) 2017 Vasantha Ganesh Kanniappan ;; Author: Herbert Valerio Riedel @@ -27,7 +28,7 @@ ;;; Code: (require 'compile) -(require 'haskell-cabal) +(require 'haskell-customize) ;;;###autoload (defgroup haskell-compile nil @@ -35,27 +36,6 @@ :link '(custom-manual "(haskell-mode)compilation") :group 'haskell) -(defcustom haskell-compile-cabal-build-command - "cd %s && cabal build --ghc-option=-ferror-spans" - "Default build command to use for `haskell-cabal-build' when a cabal file is detected. -The `%s' placeholder is replaced by the cabal package top folder." - :group 'haskell-compile - :type 'string) - -(defcustom haskell-compile-cabal-build-alt-command - "cd %s && cabal clean -s && cabal build --ghc-option=-ferror-spans" - "Alternative build command to use when `haskell-cabal-build' is called with a negative prefix argument. -The `%s' placeholder is replaced by the cabal package top folder." - :group 'haskell-compile - :type 'string) - -(defcustom haskell-compile-command - "ghc -Wall -ferror-spans -fforce-recomp -c %s" - "Default build command to use for `haskell-cabal-build' when no cabal file is detected. -The `%s' placeholder is replaced by the current buffer's filename." - :group 'haskell-compile - :type 'string) - (defcustom haskell-compile-ghc-filter-linker-messages t "Filter out unremarkable \"Loading package...\" linker messages during compilation." @@ -108,46 +88,34 @@ messages pointing to additional source locations." haskell-compilation-error-regexp-alist) (add-hook 'compilation-filter-hook - 'haskell-compilation-filter-hook nil t) - ) + 'haskell-compilation-filter-hook nil t)) ;;;###autoload -(defun haskell-compile (&optional edit-command) +(defun haskell-compile () "Compile the Haskell program including the current buffer. Tries to locate the next cabal description in current or parent -folders via `haskell-cabal-find-dir' and if found, invoke -`haskell-compile-cabal-build-command' from the cabal package root -folder. If no cabal package could be detected, -`haskell-compile-command' is used instead. - -If prefix argument EDIT-COMMAND is non-nil (and not a negative -prefix `-'), `haskell-compile' prompts for custom compile -command. - -If EDIT-COMMAND contains the negative prefix argument `-', -`haskell-compile' calls the alternative command defined in -`haskell-compile-cabal-build-alt-command' if a cabal package was -detected. +folders, `stack.yaml' file via `locate-dominating-file'. If they +are not found, then the haskell file in the currebt buffer is +executed. `haskell-compile' uses `haskell-compilation-mode' which is derived from `compilation-mode'. See Info node `(haskell-mode)compilation' for more details." - (interactive "P") + (interactive) (save-some-buffers (not compilation-ask-about-save) - compilation-save-buffers-predicate) - (let* ((cabdir (haskell-cabal-find-dir)) - (command1 (if (eq edit-command '-) - haskell-compile-cabal-build-alt-command - haskell-compile-cabal-build-command)) - (srcname (buffer-file-name)) - (command (if cabdir - (format command1 cabdir) - (if (and srcname (derived-mode-p 'haskell-mode)) - (format haskell-compile-command srcname) - command1)))) - (when (and edit-command (not (eq edit-command '-))) - (setq command (compilation-read-command command))) - + compilation-save-buffers-predicate) + (let* ((commandl (cl-ecase (haskell-process-type) + ('ghci `(,haskell-process-path-ghc + ,(buffer-file-name) + ,haskell-process-args-ghc)) + ('cabal-repl `(,haskell-process-path-cabal + "build" + ,haskell-process-args-cabal-build)) + ('stack-ghci `(,haskell-process-path-stack + "build" + ,haskell-process-args-stack-build)))) + (command (mapconcat #'concat commandl " "))) + (message command) (compilation-start command 'haskell-compilation-mode))) (provide 'haskell-compile) diff --git a/haskell-mode-test-dir31102pMV/Main.hs b/haskell-mode-test-dir31102pMV/Main.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31102pMV/Main.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31102pMV/README.md b/haskell-mode-test-dir31102pMV/README.md new file mode 100644 index 000000000..70c379b63 --- /dev/null +++ b/haskell-mode-test-dir31102pMV/README.md @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/abc.cabal b/haskell-mode-test-dir31102pMV/abc.cabal new file mode 100644 index 000000000..bdfd2d362 --- /dev/null +++ b/haskell-mode-test-dir31102pMV/abc.cabal @@ -0,0 +1 @@ +-- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/cabal.project b/haskell-mode-test-dir31102pMV/cabal.project new file mode 100644 index 000000000..bdfd2d362 --- /dev/null +++ b/haskell-mode-test-dir31102pMV/cabal.project @@ -0,0 +1 @@ +-- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/src/moduleA.hs b/haskell-mode-test-dir31102pMV/src/moduleA.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31102pMV/src/moduleA.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31102pMV/src/moduleB.hs b/haskell-mode-test-dir31102pMV/src/moduleB.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31102pMV/src/moduleB.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31102pMV/tests/test1.hs b/haskell-mode-test-dir31102pMV/tests/test1.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31102pMV/tests/test1.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31102pMV/tests/test2.hs b/haskell-mode-test-dir31102pMV/tests/test2.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31102pMV/tests/test2.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31574aOV/Main.hs b/haskell-mode-test-dir31574aOV/Main.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31574aOV/Main.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31574aOV/README.md b/haskell-mode-test-dir31574aOV/README.md new file mode 100644 index 000000000..70c379b63 --- /dev/null +++ b/haskell-mode-test-dir31574aOV/README.md @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/abc.cabal b/haskell-mode-test-dir31574aOV/abc.cabal new file mode 100644 index 000000000..bdfd2d362 --- /dev/null +++ b/haskell-mode-test-dir31574aOV/abc.cabal @@ -0,0 +1 @@ +-- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/cabal.project b/haskell-mode-test-dir31574aOV/cabal.project new file mode 100644 index 000000000..bdfd2d362 --- /dev/null +++ b/haskell-mode-test-dir31574aOV/cabal.project @@ -0,0 +1 @@ +-- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/src/moduleA.hs b/haskell-mode-test-dir31574aOV/src/moduleA.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31574aOV/src/moduleA.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31574aOV/src/moduleB.hs b/haskell-mode-test-dir31574aOV/src/moduleB.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31574aOV/src/moduleB.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31574aOV/tests/test1.hs b/haskell-mode-test-dir31574aOV/tests/test1.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31574aOV/tests/test1.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-mode-test-dir31574aOV/tests/test2.hs b/haskell-mode-test-dir31574aOV/tests/test2.hs new file mode 100644 index 000000000..cb92a800e --- /dev/null +++ b/haskell-mode-test-dir31574aOV/tests/test2.hs @@ -0,0 +1 @@ +-- Empty file diff --git a/haskell-utils.el b/haskell-utils.el index 1126a2614..cce073d89 100644 --- a/haskell-utils.el +++ b/haskell-utils.el @@ -189,5 +189,12 @@ expression bounds." If given DISABLED argument sets variable value to nil, otherwise to t." (setq haskell-mode-interactive-prompt-state (not disabled))) +(defun haskell-utils-compile-error-p () + "Return t if an error (ghci's) is found in current buffer." + (search-forward-regexp "^\\(\\(?:[A-Z]:\\)?[^ \r\n:][^\r\n:]*\\):\\([0-9()-:]+\\):?" + nil + (lambda () nil) + 1)) + (provide 'haskell-utils) ;;; haskell-utils.el ends here diff --git a/tests/haskell-compile-tests.el b/tests/haskell-compile-tests.el new file mode 100644 index 000000000..c2e6a705c --- /dev/null +++ b/tests/haskell-compile-tests.el @@ -0,0 +1,50 @@ +;;; haskell-compile-tests.el --- Tests for HsCompilation Mode -*- lexical-binding: t -*- + +;; Copyright © 2017 Vasantha Ganesh Kanniappan + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;;; Code: + +(require 'haskell-test-utils) +(require 'haskell-utils) +(require 'haskell-compile) + +(ert-deftest haskell-compile-test-1 () + (haskell-unconditional-kill-buffer "*haskell-compilation*") + (find-file-literally (concat default-directory + (file-name-as-directory "tests") + (file-name-as-directory "sample-code") + "fibonoacci.hs")) + (with-current-buffer "fibonoacci.hs" + (haskell-mode) + (haskell-compile) + (should (buffer-live-p (get-buffer "*haskell-compilation*"))))) + +(ert-deftest haskell-compile-test-2 () + (haskell-unconditional-kill-buffer "*haskell-compilation*") + (find-file-literally (concat default-directory + (file-name-as-directory "tests") + (file-name-as-directory "sample-code") + "does_not_compile.hs")) + (with-current-buffer "does_not_compile.hs" + (haskell-mode) + (haskell-compile) + (with-current-buffer "*haskell-compilation*" + (goto-char (point-min)) + (should (haskell-utils-compile-error-p))))) diff --git a/tests/sample-code/does_not_work.hs b/tests/sample-code/does_not_work.hs new file mode 100644 index 000000000..276a88ec6 --- /dev/null +++ b/tests/sample-code/does_not_work.hs @@ -0,0 +1,10 @@ +main = interact $ show . myfib . readInt + +readInt :: String -> Integer +readInt = read + +myfib :: Integer -> Integer +myfib n = (fibs) !! n + +fibs :: [Integer] +fibs = 1 : 1 : zipWith (+) fibs (tail fibs) diff --git a/tests/sample-code/fibonoacci.hs b/tests/sample-code/fibonoacci.hs new file mode 100644 index 000000000..976cf9684 --- /dev/null +++ b/tests/sample-code/fibonoacci.hs @@ -0,0 +1,10 @@ +main = interact $ show . myfib . readInt + +readInt :: String -> Int +readInt = read + +myfib :: Int -> Integer +myfib n = (fibs) !! n + +fibs :: [Integer] +fibs = 1 : 1 : zipWith (+) fibs (tail fibs) From d0b33ba5a9309436089d3b68de356c535710a636 Mon Sep 17 00:00:00 2001 From: Vasantha Ganesh K Date: Mon, 28 Aug 2017 00:21:54 +0530 Subject: [PATCH 2/4] removed unwanted files and dirs produced while testing --- haskell-mode-test-dir31102pMV/Main.hs | 1 - haskell-mode-test-dir31102pMV/README.md | 1 - haskell-mode-test-dir31102pMV/abc.cabal | 1 - haskell-mode-test-dir31102pMV/cabal.project | 1 - haskell-mode-test-dir31102pMV/src/moduleA.hs | 1 - haskell-mode-test-dir31102pMV/src/moduleB.hs | 1 - haskell-mode-test-dir31102pMV/tests/test1.hs | 1 - haskell-mode-test-dir31102pMV/tests/test2.hs | 1 - haskell-mode-test-dir31574aOV/Main.hs | 1 - haskell-mode-test-dir31574aOV/README.md | 1 - haskell-mode-test-dir31574aOV/abc.cabal | 1 - haskell-mode-test-dir31574aOV/cabal.project | 1 - haskell-mode-test-dir31574aOV/src/moduleA.hs | 1 - haskell-mode-test-dir31574aOV/src/moduleB.hs | 1 - haskell-mode-test-dir31574aOV/tests/test1.hs | 1 - haskell-mode-test-dir31574aOV/tests/test2.hs | 1 - 16 files changed, 16 deletions(-) delete mode 100644 haskell-mode-test-dir31102pMV/Main.hs delete mode 100644 haskell-mode-test-dir31102pMV/README.md delete mode 100644 haskell-mode-test-dir31102pMV/abc.cabal delete mode 100644 haskell-mode-test-dir31102pMV/cabal.project delete mode 100644 haskell-mode-test-dir31102pMV/src/moduleA.hs delete mode 100644 haskell-mode-test-dir31102pMV/src/moduleB.hs delete mode 100644 haskell-mode-test-dir31102pMV/tests/test1.hs delete mode 100644 haskell-mode-test-dir31102pMV/tests/test2.hs delete mode 100644 haskell-mode-test-dir31574aOV/Main.hs delete mode 100644 haskell-mode-test-dir31574aOV/README.md delete mode 100644 haskell-mode-test-dir31574aOV/abc.cabal delete mode 100644 haskell-mode-test-dir31574aOV/cabal.project delete mode 100644 haskell-mode-test-dir31574aOV/src/moduleA.hs delete mode 100644 haskell-mode-test-dir31574aOV/src/moduleB.hs delete mode 100644 haskell-mode-test-dir31574aOV/tests/test1.hs delete mode 100644 haskell-mode-test-dir31574aOV/tests/test2.hs diff --git a/haskell-mode-test-dir31102pMV/Main.hs b/haskell-mode-test-dir31102pMV/Main.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31102pMV/Main.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31102pMV/README.md b/haskell-mode-test-dir31102pMV/README.md deleted file mode 100644 index 70c379b63..000000000 --- a/haskell-mode-test-dir31102pMV/README.md +++ /dev/null @@ -1 +0,0 @@ -Hello world \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/abc.cabal b/haskell-mode-test-dir31102pMV/abc.cabal deleted file mode 100644 index bdfd2d362..000000000 --- a/haskell-mode-test-dir31102pMV/abc.cabal +++ /dev/null @@ -1 +0,0 @@ --- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/cabal.project b/haskell-mode-test-dir31102pMV/cabal.project deleted file mode 100644 index bdfd2d362..000000000 --- a/haskell-mode-test-dir31102pMV/cabal.project +++ /dev/null @@ -1 +0,0 @@ --- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31102pMV/src/moduleA.hs b/haskell-mode-test-dir31102pMV/src/moduleA.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31102pMV/src/moduleA.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31102pMV/src/moduleB.hs b/haskell-mode-test-dir31102pMV/src/moduleB.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31102pMV/src/moduleB.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31102pMV/tests/test1.hs b/haskell-mode-test-dir31102pMV/tests/test1.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31102pMV/tests/test1.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31102pMV/tests/test2.hs b/haskell-mode-test-dir31102pMV/tests/test2.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31102pMV/tests/test2.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31574aOV/Main.hs b/haskell-mode-test-dir31574aOV/Main.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31574aOV/Main.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31574aOV/README.md b/haskell-mode-test-dir31574aOV/README.md deleted file mode 100644 index 70c379b63..000000000 --- a/haskell-mode-test-dir31574aOV/README.md +++ /dev/null @@ -1 +0,0 @@ -Hello world \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/abc.cabal b/haskell-mode-test-dir31574aOV/abc.cabal deleted file mode 100644 index bdfd2d362..000000000 --- a/haskell-mode-test-dir31574aOV/abc.cabal +++ /dev/null @@ -1 +0,0 @@ --- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/cabal.project b/haskell-mode-test-dir31574aOV/cabal.project deleted file mode 100644 index bdfd2d362..000000000 --- a/haskell-mode-test-dir31574aOV/cabal.project +++ /dev/null @@ -1 +0,0 @@ --- Empty file \ No newline at end of file diff --git a/haskell-mode-test-dir31574aOV/src/moduleA.hs b/haskell-mode-test-dir31574aOV/src/moduleA.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31574aOV/src/moduleA.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31574aOV/src/moduleB.hs b/haskell-mode-test-dir31574aOV/src/moduleB.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31574aOV/src/moduleB.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31574aOV/tests/test1.hs b/haskell-mode-test-dir31574aOV/tests/test1.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31574aOV/tests/test1.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file diff --git a/haskell-mode-test-dir31574aOV/tests/test2.hs b/haskell-mode-test-dir31574aOV/tests/test2.hs deleted file mode 100644 index cb92a800e..000000000 --- a/haskell-mode-test-dir31574aOV/tests/test2.hs +++ /dev/null @@ -1 +0,0 @@ --- Empty file From 9bee28c24de560a9629f10b9faf7bd923bf2f608 Mon Sep 17 00:00:00 2001 From: Vasantha Ganesh K Date: Mon, 28 Aug 2017 01:06:52 +0530 Subject: [PATCH 3/4] compilation docs --- doc/haskell-mode.texi | 203 +++++++++++++++++++++++++++++------------- 1 file changed, 139 insertions(+), 64 deletions(-) diff --git a/doc/haskell-mode.texi b/doc/haskell-mode.texi index 3fc1291ad..8735efdad 100644 --- a/doc/haskell-mode.texi +++ b/doc/haskell-mode.texi @@ -1076,78 +1076,153 @@ line in the right file when clicked/selected. @node Compilation @chapter Compilation -@findex haskell-compile +Haskell Mode comes with an intelligent Major mode for compilation named +@code{HsCompilation} defined in @code{haskell-compile.el}. This mode is +derived from @code{compilation-mode} defined in @code{compile.el}. -Haskell mode comes equipped with a specialized @dfn{Compilation mode} -tailored to GHC's compiler messages with optional support for Cabal -projects. @xref{Compilation Mode,,,emacs}, for more information about -the basic commands provided by the Compilation mode which are available -in the Haskell compilation sub-mode as well. The additional features -provided compared to Emacs' basic Compilation mode are: +First the compilation mode tries to find the project's root directory. +This is done by searching for files such as @code{cabal.sandbox.config}, +@code{stack.yaml}, and @code{something.cabal} in that order. -@itemize -@item -DWIM-style auto-detection of compile command (including support for -CABAL projects) -@item -Support for GHC's compile messages and recognizing error, warning and -info source locations (including @option{-ferror-spans} syntax) -@item -Support for filtering out GHC's uninteresting @samp{Loading package...} -linker messages -@end itemize +If you have both @code{cabal.sandbox.config} and @code{stack.yaml} files +defined, in your project's root directory, @code{cabal.sandbox.config} +takes precedence over @code{stack.yaml} and similary @code{stack.yaml} +takes precedence over @code{something.cabal}. -In order to use it, invoke the @code{haskell-compile} command instead of -@code{compile} as you would for the ordinary Compilation mode. It's -recommended to bind @code{haskell-compile} to a convenient key -binding. For instance, you can add the following to your Emacs -initialization to bind @code{haskell-compile} to @kbd{C-c C-c}. +You can start the compilation by @kbd{M-x haskell-compile}. The intelligent +thing about this mode is that like it sets the project's root directory. +It will run the appropriate compilation command from the project's root +directory. -@lisp -(eval-after-load "haskell-mode" - '(define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile)) +@multitable @columnfractions 0.25 0.25 0.50 +@headitem Dominant file @tab Build command @tab Commandline Options -(eval-after-load "haskell-cabal" - '(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile)) -@end lisp +@item @code{cabal.sandbox.config} +@tab @code{cabal build} +@tab @code{--ghc-options=\"-ferror-spans -Wall -fforce-recomp\"} -@noindent -The following description assumes that @code{haskell-compile} has been -bound to @kbd{C-c C-c}. - -@vindex haskell-compile-cabal-build-command -@vindex haskell-compile-cabal-build-command-alt -@vindex haskell-compile-command - -When invoked, @code{haskell-compile} tries to guess how to compile the -Haskell program your currently visited buffer belongs to, by searching -for a @file{.cabal} file in the current of enclosing parent folders. If -a @file{.cabal} file was found, the command defined in the -@code{haskell-compile-cabal-build-command} option is used. Note that to -compile a @code{stack} based project you will need to set this variable to -@code{stack build}. As usual you can do it using @code{M-x customize-variable} -or with: +@item @code{stack.yaml} +@tab @code{stack build} +@tab @code{--ghc-options=\"-ferror-spans -Wall\"} -@lisp -(setq haskell-compile-cabal-build-command "stack build") -@end lisp +@item @code{something.cabal} +@tab @code{cabal build} + +@item default +@tab @code{ghc } +@tab @code{--make -ferror-spans -Wall -fforce-recomp} +@end multitable + +@section Keybindings + +@multitable @columnfractions 0.3 0.7 +@headitem Key binding @tab Function +@item TAB +@tab compilation-next-error + +@item RET +@tab compile-goto-error + +@item C-o +@tab compilation-display-error + +@item SPC +@tab scroll-up-command + +@item - +@tab negative-argument + +@item 0 .. 9 +@tab digit-argument + +@item < +@tab beginning-of-buffer + +@item > +@tab end-of-buffer + +@item ? +@tab describe-mode + +@item g +@tab recompile + +@item h +@tab describe-mode + +@item q +@tab quit-window + +@item DEL +@tab scroll-down-command + +@item S-SPC +@tab scroll-down-command + +@item +@tab compilation-previous-error + +@item +@tab mouse-face + +@item +@tab compile-goto-error + +@item +@tab Prefix Command + +@item M-n +@tab compilation-next-error + +@item M-p +@tab compilation-previous-error + +@item M-@{ +@tab compilation-previous-file + +@item M-@} +@tab compilation-next-file + +@item C-c C-c +@tab compile-goto-error + +@item C-c C-f +@tab next-error-follow-minor-mode + +@item C-c C-k +@tab kill-compilation + +@end multitable + +@section Related Defcustoms + +@multitable @columnfractions 0.3 0.7 +@headitem Defcustom @tab Default Value + +@item @code{haskell-process-path-ghc} +@tab @code{ghc} + +@item @code{haskell-process-args-ghc} +@tab @code{--make -ferror-spans -Wall -fforce-recomp} + +@item @code{haskell-process-path-cabal} +@tab @code{cabal} + +@item @code{haskell-process-args-cabal-build} +@tab @code{--ghc-options=\"-ferror-spans -Wall -fforce-recomp\"} + +@item @code{haskell-process-path-stack} +@tab @code{stack} + +@item @code{haskell-process-args-stack-build} +@tab @code{--ghc-options=\"-ferror-spans -Wall\"} +@end multitable + +@item @code{} + +@section Hooks -Moreover, when requesting to compile a @file{.cabal}-file is detected and -a negative prefix argument (e.g. @kbd{C-- C-c C-c}) was given, the -alternative @code{haskell-compile-cabal-build-command-alt} is -invoked. By default, @code{haskell-compile-cabal-build-command-alt} -contains a @samp{cabal clean -s} command in order to force a full -rebuild. - -Otherwise if no @file{.cabal} could be found, a single-module -compilation is assumed and @code{haskell-compile-command} is used -(@emph{if} the currently visited buffer contains Haskell source code). - -You can also inspect and modify the compile command to be invoked -temporarily by invoking @code{haskell-compile} with a prefix argument -(e.g. @kbd{C-u C-c C-c}). If later-on you want to recompile using the -same customized compile command, invoke @code{recompile} (bound to -@kbd{g}) inside the @samp{*haskell-compilation*} buffer. +None @node Inferior Haskell interpreter @chapter Inferior Haskell interpreter From 62fb53e0e643e43e8d24abd622ab5c8a36006952 Mon Sep 17 00:00:00 2001 From: Vasantha Ganesh K Date: Mon, 28 Aug 2017 01:23:13 +0530 Subject: [PATCH 4/4] bug fix in haskell-mode.texi --- doc/haskell-mode.texi | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/haskell-mode.texi b/doc/haskell-mode.texi index 8735efdad..0ca51bbca 100644 --- a/doc/haskell-mode.texi +++ b/doc/haskell-mode.texi @@ -1218,8 +1218,6 @@ directory. @tab @code{--ghc-options=\"-ferror-spans -Wall\"} @end multitable -@item @code{} - @section Hooks None