Last active
May 1, 2017 21:11
-
-
Save noprompt/56214379faf2fae2599826a31307c1bb to your computer and use it in GitHub Desktop.
Intero scratch buffer which provides minimal facilities for sending code to the Intero REPL.
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
(defun intero-scratch-send-paragraph () | |
(interactive) | |
(let* ((source-code-start (save-excursion | |
(backward-paragraph) | |
(point))) | |
(source-code-end (save-excursion | |
(forward-paragraph) | |
(point))) | |
(source-code (buffer-substring-no-properties source-code-start | |
source-code-end)) | |
(repl-buffer (intero-repl-buffer nil)) | |
(intero-process (get-buffer-process repl-buffer))) | |
(with-current-buffer repl-buffer | |
(dolist (line (split-string (concat ":{\n" | |
(string-trim source-code) | |
"\n:}") | |
"\n")) | |
(goto-char (point-max)) | |
(insert line) | |
(sleep-for 0 5) | |
(call-interactively (key-binding (kbd "<RET>"))))))) | |
(defun intero-scratch () | |
(interactive) | |
(let ((maybe-intero-scratch-buffer (get-buffer "*intero-scratch*"))) | |
(if maybe-intero-scratch-buffer | |
(pop-to-buffer maybe-intero-scratch-buffer) | |
(let ((intero-scratch-buffer (get-buffer-create "*intero-scratch*"))) | |
(with-current-buffer intero-scratch-buffer | |
(haskell-font-lock-defaults-create) | |
(font-lock-mode) | |
(local-set-key (kbd "C-c C-c") 'intero-scratch-send-paragraph)) | |
(pop-to-buffer inter-scratch-buffer))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment