Skip to content

Commit

Permalink
Squashed 'site-lisp/haskell-mode/' changes from 6a4d4bd..47d90c8
Browse files Browse the repository at this point in the history
47d90c8 Support multiple presentations at once in the same REPL
d027f9f Thread hash through presentation functions
a0dd740 Split interaction mode into two minor modes a la indentation
591d1a8 Fix inserting of type in haskell-describe
5c817ee Add initial haskell-describe function
e300782 Add import suggestions based on haskell-docs
050a119 Support 7.8 in extension completion
faf4c56 Support GHC 7.8's message format for extension suggestions
d62f51a Improve usefulness of file-relative-name in cycle code
36e39a4 Pick up import cycles as loading errors with fake line numbers
073344e Merge pull request #282 from bergey/cabal-path
52fafce Merge pull request #284 from ryantm/byte-compile-warnings
a73cb69 add missing requires in haskell-debug
905faf5 Merge pull request #283 from ryantm/byte-compile-warnings
ae0e87c Add try-type
95dbb75 do not require w3m
5ffbf1d stop using goto-line as recommended by emacs help on goto-line
8f02b8c Use haskell-process-path-cabal everywhere
ca84191 Make popups disableable (fixes #280)
f7f1a17 Show ... if more results in module completion, a la ido-mode
5985f84 Use `haskell-complete-module' for module completions
e49c0e5 Satisfy Makefile warnings for haskell-complete-module
c285ee3 Fix e reference in haskell-process.el
55b9c7c Add haskell-complete-module
a8c4c12 Don't ask about importing the same module more than once
d3f3f5b Handle errors and quitting in process commands more gracefully
89917d2 Skip whole module qualification in hoogle import suggestions
76c505d Add kill-whole-line support in REPL (closes #277)
2df11b6 Fix warning detection regex (fixes #275)
cda2fc8 Merge pull request #274 from Philonous/master
69ead72 Fix getLine with no stdout output
9f65077 curb process restart spam
c2206c9 Remove debug message
976917b Add back padding option in haskell-align-imports (#183)
3d834d4 Fix OverloadedStrings suggester
cc161d7 Test cases for haskell-sort-imports (#270)
fbdc679 Sort on just module names (#270)
8f2a7e0 Rewrite sort-imports to not be line-based (#270)
efe9bbe Make sure to expand filename when getting definition dir
c58058e Trivial function for dumping minimal imports
832fcc6 Fix haskell-process-hoogle-ident
02fedeb Experimental refactor of jumping to definition
ed148c9 Fix make build for Emacs 23
b180578 Throw error if trying to create a session that already exists
ff2f361 Improve session switching
c8a72bd Avoid prompting on incomplete sessions when sifting
52b93a6 Fix face references in haskell-debug (fixes #268)
ee537a5 Fix Show detection in presence of newline
5df78d2 Fix ill-advised removal of prompt stripping
1eb2b2b Let haskell-process-hoogle-ident fail silently on error
116e66a Add hoogle server commands
88b4091 Modify hoogle-suggest regexes for ghc 7.8 compatibility
23b385b Additional fix for ghci prompt inferior-haskell-mode
8fbc5f6 Support stdin input in the REPL
e827a17 Remove redundant newline in colorized output
7fb632a Update README to ref wiki manual
cefa9e9 Make showing types of ambiguous/no-show expressions customizable
7102355 Show types for ambiguous type variables in the REPL, too
a22f7a1 Make import questioning more persistent at getting an answer
33f0011 Add module template auto-insertion function
8a774c7 Support arbitrary cabal command
e9934ab Fix auto-type-showing in presence of :set +t
e1a0d86 Show the type of something if no Show instance is available
c4dc84f Add require cl
c6d22db Fix format of customization of -w3m-haddock-dirs
fa0835f Handle unrepresentable things in :present
9073057 Update to present-1.0 (you need to cabal install present==1.0)
007f585 Fix to pass make check
7c1d6b1 Fix missing function reference
254ba72 Handle compile messages from GHC that contain [TH]
9324171 Much better list presentations
18713e6 Indent alg-types with newlines and regular indentation
5f90c1d Support multiple directories in w3m-haddock
eddb5c1 Add preliminary :present support
f6c4b86 Fix error in haskell-interactive-mode completion (#263)
5e4907f Fix spacing in type info regression (#264)
aa07205 Popup error buffer instead of displaying them in the REPL
35527f9 Add sexp-based collapsing support in REPL
099c82c Strip newlines from haskell-process-do-type
5128d4d Fix haskell-debug for recent prompt handling changes.
433c16a Dump complete output if zero compiler messages from cabal
b5ca602 Strip out extraneous prompts
58810a1 Declare use of -insert-garbage
c2e7dbf Echo extraneous output after prompt has been received
277e8e8 Use end-of-transmission for prompt
d9aa484 Only save again after stylish if necessary.
3d1ff09 Print a newline as soon as the command starts to execute.
a0a33d3 Make haskell-align-imports-padding a total function
110aa35 Add a command to send cabal macros (#255)
e9587d9 Make haskell-interactive-at-prompt return position
f1962fe Add back 'break properties to breakpoint list
c621a21 Support next/previous properly
0963af4 Reset history and bindings cache after abandoning
f0748c2 Re-step after reloading
af495c2 Debugger with bindings display
d2ba091 Keep hold of the back trace for helpful display at the end
6219ad6 Good progress on debugger stepping
d5b3577 fixes #250, haskell-interactive mode broken under certain conditions
92581b1 A bit more of the debugger mode
69fe380 Start of implementation of interactive debugger
aec3d05 Add .dump-simpl files to ghc-core auto-mode-alist
6bb7cad More liberal source match
92f2f26 Add customization setting for header color
6bd7c56 Add haskell-w3m-open-haddock
c1f982e Remove accidentally left in font-lock experiment
9b43204 Add multi-line support in REPL
5a3a996 Add haskell-process-reload-devel-main interactive command
2684a4f Use marker instead of regexps in haskell-interactive-mode prompt
5ce988e Support continuations in the process loading
6bec474 Add w3m-haddock.el
7ddc44f Disable hoogle suggestion by default
6ca09d0 Replace completing-read-function with custom for haskell-mode
1248ab0 Defvar completing-read-function
4bcb2db Declare 'delete-active-region' in haskell-indentation
ec00623 Replace 'ido-completing-read' with 'completing-read-function'
1af6521 Another attempt at removing EOF newline.
2a97e4c Remove EOF newline. These are explicit in snippets.
6615415 Ability to configure the import line on suggestions
17c8a28 Fix dynamic-binding reference
96ffb1f Separate running a line in haskell-interactive-mode into another function
1db9dde Use && instead of ; because this works on Windows, too (refs #232)
1834c3b Option to automatically chmod .ghci files that GHCi ignores
55408fc Make showing debugging tips an option
692afb9 Make errors expanded by default
7b3946d Check for build/install as substring
a4a8a09 Allow whitespace before settings.
182e34f Don't use replace-regexp to appease make check
1c6ef10 Support god-mode on SPC key
175c6cc Better "not in scope" detection
ab7ee92 Strip out M./S./L. typical module prefixes for suggestion functionality
38e8c06 Make navigate-imports a bit more useful in absense of import list
c85219a Ignore package results
5ae3835 Support the case of multiple available modules for auto-import
89b036d Automatically add package to cabal file
f44c2d3 Make dummy global binding to avoid not-in-scope warnings
ed4d9e8 Automatically add import lines via Hoogle
9292ba1 Fix undefined reference to shm-display-quarantine in haskell-present
fa1b365 Support jumping to filenames inside strings
7e74535 Small indentation fix
0ae55ff Quick hack to remove "Compilation failed" line
f13eae5 Support commenting out of imports
dc3a02f Add a function to guess the module name of the current buffer
c910ed0 Don't show shm's display quarantines in presentation mode
3f7747e Fix delete-backward-char in haskell-indentation (fixes #211)
3ade6a8 Merge pull request #214 from brandonw/master
29c0b98 Merge pull request #217 from adimit/patch-1
c9424aa add support for cabal repl build targets
7ae7411 Add haskell-bot.el, for interacting with locally installed lambdabot
54e6ccd Fix import.qualified.
4f87331 Fix internal GHC module translation
c925867 Revert "Fix internal GHC module translation"
43f2747 Always use the ident as an anchor
0ff0841 Update internal GHC module translations
53a63a1 Fix internal GHC module translation

git-subtree-dir: site-lisp/haskell-mode
git-subtree-split: 47d90c8
  • Loading branch information
jwiegley committed Sep 14, 2015
1 parent 2d750be commit 924ac7c
Show file tree
Hide file tree
Showing 22 changed files with 3,020 additions and 331 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -20,12 +20,14 @@ ELFILES = \
haskell-font-lock.el \
haskell-indent.el \
haskell-indentation.el \
haskell-collapse.el \
haskell-interactive-mode.el \
haskell-menu.el \
haskell-mode.el \
haskell-move-nested.el \
haskell-navigate-imports.el \
haskell-package.el \
haskell-complete-module.el \
haskell-process.el \
haskell-session.el \
haskell-show.el \
Expand Down
22 changes: 17 additions & 5 deletions README.md
Expand Up @@ -3,8 +3,20 @@ Haskell Mode for Emacs

[![Build Status](https://travis-ci.org/haskell/haskell-mode.png?branch=master)](https://travis-ci.org/haskell/haskell-mode)

This is the Haskell mode package for Emacs. Its use should be mostly
self-explanatory if you're accustomed to Emacs.
This is the Haskell mode package for Emacs.

Please see
[the online haskell-mode manual](https://github.com/haskell/haskell-mode/wiki)
for setup and use guide.

To report problems or suggestions, please
[open an issue](https://github.com/haskell/haskell-mode/issues?state=open)
in the issue tracker.

Below is a brief setup guide.

Quick Emacs rundown
--------------------

When Emacs is started up, it normally loads the
[Emacs initialization file](http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html)
Expand Down Expand Up @@ -110,13 +122,13 @@ $ apt-get install haskell-mode

- Invoking `make haskell-mode-autoloads.el`, or `make all` (use
this to perform byte-compilation and Info manual generation)

- From inside Emacs, `M-x update-directory-autoloads` and answering the question for
the folder with `~/lib/emacs/haskell-mode/` and the question for the output-file with
`~/lib/emacs/haskell-mode/haskell-mode-autoloads.el`

and then adding the following command to your `.emacs`:

```el
(add-to-list 'load-path "~/lib/emacs/haskell-mode/")
(require 'haskell-mode-autoloads)
Expand Down
2 changes: 1 addition & 1 deletion ghc-core.el
Expand Up @@ -29,7 +29,6 @@
;; and removal of commonly ignored annotations.

;;; Code:

(require 'haskell-mode)
(require 'haskell-font-lock)

Expand Down Expand Up @@ -112,6 +111,7 @@ in the current buffer."

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.hcr\\'" . ghc-core-mode))
(add-to-list 'auto-mode-alist '("\\.dump-simpl\\'" . ghc-core-mode))

;;;###autoload
(define-derived-mode ghc-core-mode haskell-mode "GHC-Core"
Expand Down
70 changes: 58 additions & 12 deletions haskell-align-imports.el
Expand Up @@ -48,6 +48,30 @@
;; When haskell-align-imports is run within the same buffer, the
;; import list is transformed to:
;;
;; import "abc" Eight
;; import qualified Eighteen as PRELUDE hiding (A)
;; import qualified "defg" Eleven as PRELUDE
;; import Fifteen hiding (A)
;; import Five (A)
;; import qualified Four as PRELUDE
;; import qualified "z" Fourteen (A,B)
;; import "abc" Nine as TWO
;; import "abc" Nineteen hiding (A)
;; import One
;; import qualified Seven (A,B)
;; import qualified Seventeen hiding (A)
;; import Six (A,B)
;; import Sixteen as TWO hiding (A)
;; import qualified "abc" Ten
;; import "zotconpop" Thirteen (A,B)
;; import qualified Three
;; import "barmu" Twelve (A)
;; import "abc" Twenty as TWO hiding (A)
;; import Two as A
;;
;; If you want everything after module names to be padded out, too,
;; customize `haskell-align-imports-pad-after-name', and you'll get:
;;
;; import One
;; import Two as A
;; import qualified Three
Expand Down Expand Up @@ -77,7 +101,18 @@
(concat "^\\(import[ ]+\\)"
"\\(qualified \\)?"
"[ ]*\\(\"[^\"]*\" \\)?"
"[ ]*\\([A-Za-z0-9_.']*.*\\)"))
"[ ]*\\([A-Za-z0-9_.']+\\)"
"[ ]*\\([ ]*as [A-Z][^ ]*\\)?"
"[ ]*\\((.*)\\)?"
"\\([ ]*hiding (.*)\\)?"
"\\( -- .*\\)?[ ]*$")
"Regex used for matching components of an import.")

(defcustom haskell-align-imports-pad-after-name
nil
"Pad layout after the module name also."
:type 'boolean
:group 'haskell-interactive)

;;;###autoload
(defun haskell-align-imports ()
Expand Down Expand Up @@ -131,14 +166,23 @@
"")
b))
ls))))
(list (funcall join (list (aref parts 0)
(aref parts 1)
(aref parts 2)))
(aref parts 3)
(funcall join (list (aref parts 4)
(aref parts 5)
(aref parts 6)))
(aref parts 7))))
(if haskell-align-imports-pad-after-name
(list (funcall join (list (aref parts 0)
(aref parts 1)
(aref parts 2)))
(aref parts 3)
(funcall join (list (aref parts 4)
(aref parts 5)
(aref parts 6)))
(aref parts 7))
(list (funcall join (list (aref parts 0)
(aref parts 1)
(aref parts 2)))
(funcall join (list (aref parts 3)
(aref parts 4)
(aref parts 5)
(aref parts 6)
(aref parts 7)))))))

(defun haskell-align-imports-chomp (str)
"Chomp leading and tailing whitespace from STR."
Expand All @@ -149,9 +193,11 @@

(defun haskell-align-imports-padding (imports)
"Find the padding for each part of the import statements."
(reduce (lambda (a b) (mapcar* #'max a b))
(mapcar (lambda (x) (mapcar #'length (car x)))
imports)))
(if (null imports)
imports
(reduce (lambda (a b) (mapcar* #'max a b))
(mapcar (lambda (x) (mapcar #'length (car x)))
imports))))

(defun haskell-align-imports-fill (padding line)
"Fill an import line using the padding worked out from all statements."
Expand Down
176 changes: 176 additions & 0 deletions haskell-bot.el
@@ -0,0 +1,176 @@
;;; haskell-bot.el --- A Lambdabot interaction mode

;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Copyright (C) 2001 Chris Webb
;; Copyright (C) 1998, 1999 Guy Lapalme

;; Keywords: inferior mode, Bot interaction mode, Haskell

;;; This file is not part of GNU Emacs.

;; 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., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.


;;; Commentary:

;; Purpose:
;;
;; To send a Haskell buffer to another buffer running a Bot
;; interpreter.
;;
;; This mode is derived from version 1.1 of Guy Lapalme's
;; haskell-hugs.el, which can be obtained from:
;;
;; http://www.iro.umontreal.ca/~lapalme/Hugs-interaction.html
;;
;; This in turn was adapted from Chris Van Humbeeck's hugs-mode.el,
;; which can be obtained from:
;;
;; http://www-i2.informatik.rwth-aachen.de/Forschung/FP/Haskell/hugs-mode.el
;;
;;
;; Installation:
;;
;; To use with Moss and Thorn's haskell-mode.el
;;
;; http://www.haskell.org/haskell-mode
;;
;; add this to .emacs:
;;
;; (add-hook 'haskell-mode-hook 'turn-on-haskell-bot)
;;
;;
;; Customisation:
;;
;; The name of the Bot interpreter is in haskell-bot-program-name.
;;
;; Arguments can be sent to the Bot interpreter when it is started by
;; setting haskell-bot-program-args (empty by default) to a list of
;; string args to pass it. This value can be set interactively by
;; calling C-c C-s with an argument (i.e. C-u C-c C-s).
;;
;; `haskell-bot-hook' is invoked in the *bot* buffer once Bot is
;; started.
;;
;; All functions/variables start with `turn-{on,off}-haskell-bot' or
;; `haskell-bot-'.

;;; Code:

(defgroup haskell-bot nil
"Major mode for interacting with an inferior Bot session."
:group 'haskell
:prefix "haskell-bot-")

(define-derived-mode haskell-bot-mode comint-mode "Lambdabot")

;; Bot interface:

(require 'comint)
(require 'shell)

(defvar haskell-bot-process nil
"The active Bot subprocess corresponding to current buffer.")

(defvar haskell-bot-process-buffer nil
"*Buffer used for communication with Bot subprocess for current buffer.")

(defcustom haskell-bot-program-name "lambdabot"
"*The name of the Bot interpreter program."
:type 'string
:group 'haskell-bot)

(defcustom haskell-bot-program-args nil
"*A list of string args to pass when starting the Bot interpreter."
:type '(repeat string)
:group 'haskell-bot)

(defvar haskell-bot-load-end nil
"Position of the end of the last load command.")

(defvar haskell-bot-error-pos nil
"Position of the end of the last load command.")

(defvar haskell-bot-send-end nil
"Position of the end of the last send command.")

(defvar haskell-bot-comint-prompt-regexp
"^lambdabot> "
"A regexp that matches the Bot prompt.")

(defun haskell-bot-start-process (arg)
"Start a Bot process and invoke `haskell-bot-hook' if not nil.
Prompt for a list of args if called with an argument."
(interactive "P")
(if arg
;; XXX [CDW] Fix to use more natural 'string' version of the
;; XXX arguments rather than a sexp.
(setq haskell-bot-program-args
(read-minibuffer (format "List of args for %s:"
haskell-bot-program-name)
(prin1-to-string haskell-bot-program-args))))

;; Start the Bot process in a new comint buffer.
(message "Starting Lambdabot process `%s'." haskell-bot-program-name)
(setq haskell-bot-process-buffer
(apply 'make-comint
"lambdabot" haskell-bot-program-name nil
haskell-bot-program-args))
(setq haskell-bot-process
(get-buffer-process haskell-bot-process-buffer))

;; Select Bot buffer temporarily.
(set-buffer haskell-bot-process-buffer)
(haskell-bot-mode)
(setq comint-prompt-regexp haskell-bot-comint-prompt-regexp)

;; History syntax of comint conflicts with Haskell, e.g. !!, so better
;; turn it off.
(setq comint-input-autoexpand nil)
(setq comint-process-echoes nil)
(run-hooks 'haskell-bot-hook)

;; Clear message area.
(message ""))

(defun haskell-bot-wait-for-output ()
"Wait until output arrives and go to the last input."
(while (progn
(goto-char comint-last-input-end)
(not (re-search-forward comint-prompt-regexp nil t)))
(accept-process-output haskell-bot-process)))

(defun haskell-bot-send (&rest string)
"Send `haskell-bot-process' the arguments (one or more strings).
A newline is sent after the strings and they are inserted into the
current buffer after the last output."
(haskell-bot-wait-for-output) ; wait for prompt
(goto-char (point-max)) ; position for this input
(apply 'insert string)
(comint-send-input)
(setq haskell-bot-send-end (marker-position comint-last-input-end)))

(defun haskell-bot-show-bot-buffer ()
"Go to the *bot* buffer."
(interactive)
(if (or (not haskell-bot-process-buffer)
(not (buffer-live-p haskell-bot-process-buffer)))
(haskell-bot-start-process nil))
(pop-to-buffer haskell-bot-process-buffer))

(provide 'haskell-bot)

;;; haskell-bot.el ends here
2 changes: 1 addition & 1 deletion haskell-cabal.el
Expand Up @@ -133,7 +133,7 @@
(let ((case-fold-search t))
(goto-char (point-min))
(when (re-search-forward
(concat "^" (regexp-quote name)
(concat "^[ \t]*" (regexp-quote name)
":[ \t]*\\(.*\\(\n[ \t]+[ \t\n].*\\)*\\)")
nil t)
(let ((val (match-string 1))
Expand Down

0 comments on commit 924ac7c

Please sign in to comment.