Last active
June 18, 2019 14:01
-
-
Save nkpart/cc852b43d948a33a04c8 to your computer and use it in GitHub Desktop.
Using ghcid inside of emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pieces you need: | |
* emacs | |
* ghcid | |
ghcid needs to know the height of the terminal, we'll set it explicitly | |
height = (window-height) - (scroll-margin) - 1 | |
set this height as your term-buffer-maximum-size | |
(setq term-buffer-maximum-size XXX) | |
Start an ansi-term session using bash | |
SPC-' | |
run ghcid with this height, in your project root | |
ghcid -c "cabal repl" -h HEIGHT | |
turn on compilation-minor-mode in the buffer | |
@nkpart I wrote the following helper based on your notes, seems to work okay so far:
(defun ghcid ()
"Runs ghcid in a `term' buffer."
(interactive)
(require 'term)
(let* ((cmd "ghcid")
(h (- (window-height) scroll-margin 3))
(term-buffer-maximum-size h)
(args (format "-h %d" h))
(switches (split-string-and-unquote args))
(termbuf (apply 'make-term "ghcid" cmd nil switches)))
(set-buffer termbuf)
(term-mode)
(term-char-mode)
(compilation-minor-mode)
(switch-to-buffer termbuf)))
I put project-specific configuration into .ghci
and .ghcid
files, so don't need to provide any further command-line arguments to ghcid
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't have to set the height. It sort of works. Error navigation works on some lines, but not on others. After using error navigation, when ghcid renders the new build output it doesn't scroll the terminal buffer. Is this also your experience, @nkpart, or am I missing something?