diff --git a/Makefile b/Makefile index 557883bdc..4c2887fdf 100644 --- a/Makefile +++ b/Makefile @@ -20,5 +20,3 @@ test-haskell: .PHONY: ghci-test ghci-test: stack ghci --main-is=haskell-ide-test - - diff --git a/elisp/hie.el b/elisp/hie.el index 6f301db6a..b2dd350f5 100644 --- a/elisp/hie.el +++ b/elisp/hie.el @@ -174,8 +174,8 @@ association lists and count on HIE to use default values there." type-info)))) (defmacro hie-with-refactor-buffer (&rest body) - '(setq hie-refactor-buffer (get-buffer-create "*hie-refactor*")) - `(with-current-buffer hie-refactor-buffer ,@body)) + `(progn (setq hie-refactor-buffer (get-buffer-create "*hie-refactor*")) + (with-current-buffer hie-refactor-buffer ,@body))) (defmacro hie-literal-save-excursion (&rest body) "Like save-excursion but preserves line and column instead of point" @@ -190,8 +190,8 @@ association lists and count on HIE to use default values there." (-if-let (((&alist 'first first 'second second 'diff diff)) refactor) (progn (hie-with-refactor-buffer - (erase-buffer) - (insert diff)) + (erase-buffer) + (insert diff)) (let ((refactored-buffer (create-file-buffer second)) (old-buffer (or (find-buffer-visiting first) (create-file-buffer first)))) @@ -310,17 +310,19 @@ Keymap: :keymap 'hie-mode-map (if hie-mode - (unless (hie-process-live-p) - (hie-start-process) + (progn + (unless (hie-process-live-p) + (hie-start-process)) (setq hie-process-handle-message #'hie-handle-first-plugins-command) (hie-post-message '(("cmd" . "base:plugins")))) ;; we need to kill hie if this is the last one buffer standing - (unless (cl-find-if (lambda (buffer) - (with-current-buffer buffer - (bound-and-true-p hie-mode))) (buffer-list)) - (hie-kill-process)))) + (progn + (unless (cl-find-if (lambda (buffer) + (with-current-buffer buffer + (bound-and-true-p hie-mode))) (buffer-list)) + (hie-kill-process))))) (provide 'hie) diff --git a/elisp/tests/hie-tests.el b/elisp/tests/hie-tests.el index fd374478f..b10a74a52 100644 --- a/elisp/tests/hie-tests.el +++ b/elisp/tests/hie-tests.el @@ -231,6 +231,24 @@ http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15990." (cons 'type "text") (cons 'val param2))))) test-command)))) +(hie-define-test + hie-can-hare-rename + (save-excursion + (find-file "test/testdata/HaReRename.hs") + (move-to-column 0) + (goto-line 4) + (hie-mode) + (really-sleep-for 10 (lambda () (fboundp 'hie-hare-rename))) + (hie-hare-rename "foo_renamed") + (really-sleep-for + 100 + (lambda () + (equal "\nmain = putStrLn \"hello\"\n\nfoo_renamed :: Int -> Int\nfoo_renamed x = x + 3\n\n" + (buffer-substring-no-properties (point-min) (point-max))))) + (let ((refactored-string (buffer-substring-no-properties (point-min) (point-max)))) + (revert-buffer nil t) + (should (equal "\nmain = putStrLn \"hello\"\n\nfoo_renamed :: Int -> Int\nfoo_renamed x = x + 3\n\n" + refactored-string)))))