From b9df6006dba36b4383d72ff13e6a661c5f2d2f47 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Fri, 19 Feb 2016 10:31:05 +0000 Subject: [PATCH] Revert "Remove suggested imports completely" --- haskell-interactive-mode.el | 29 +++++-------------------- tests/interactive-haskell-mode-tests.el | 11 +++++----- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/haskell-interactive-mode.el b/haskell-interactive-mode.el index 81c9c60a3..20b667a1c 100644 --- a/haskell-interactive-mode.el +++ b/haskell-interactive-mode.el @@ -584,7 +584,7 @@ SESSION in specified FILE to remove IMPORT on given LINE." (cl-case (read-event (propertize (format "%sThe import line `%s' is redundant. Remove? (y, n, c: comment out) " (if (not first) - "Please answer y, n or c: " + "Please answer n, y or c: " "") import) 'face @@ -594,9 +594,9 @@ SESSION in specified FILE to remove IMPORT on given LINE." (save-excursion (goto-char (point-min)) (forward-line (1- line)) - (let ((bounds (haskell-interactive-mode--import-statement-bounds))) - (delete-region (car bounds) (cdr bounds)) - (kill-line 1)))) + (goto-char (line-beginning-position)) + (delete-region (line-beginning-position) + (line-end-position)))) (?n (message "Ignoring redundant import %s" import)) (?c @@ -604,28 +604,11 @@ SESSION in specified FILE to remove IMPORT on given LINE." (save-excursion (goto-char (point-min)) (forward-line (1- line)) - (let ((bounds (haskell-interactive-mode--import-statement-bounds))) - (comment-region (car bounds) (cdr bounds)))))) + (goto-char (line-beginning-position)) + (insert "-- ")))) ;; unwind (haskell-mode-toggle-interactive-prompt-state t)))) -(defun haskell-interactive-mode--import-statement-bounds () - "For internal use in `haskell-process-suggest-remove-import'. -This function supposed to be called having point placed on first -line of import statement, if this is a case it search import -statement bounds relying on layout and returns them as cons cell; -otherwise returns nil." - (save-excursion - (goto-char (line-beginning-position)) - (when (looking-at-p (regexp-quote "import")) - (let ((a (point)) - (z (line-end-position))) - (forward-line 1) - (while (looking-at-p (rx (and not-newline (1+ whitespace)))) - (setq z (line-end-position)) - (forward-line 1)) - (cons a z))))) - (defun haskell-process-find-file (session file) "Find the given file in the project." (find-file (cond ((file-exists-p (concat (haskell-session-current-dir session) "/" file)) diff --git a/tests/interactive-haskell-mode-tests.el b/tests/interactive-haskell-mode-tests.el index a7e416a0f..f87e1eec3 100644 --- a/tests/interactive-haskell-mode-tests.el +++ b/tests/interactive-haskell-mode-tests.el @@ -32,21 +32,20 @@ (require 'ert) (require 'haskell-interactive-mode) +(defun should-match (str) + (should (eq 0 (string-match-p haskell-interactive-mode-error-regexp str)))) + (ert-deftest haskell-interactive-error-regexp-test () "Tests the regexp `haskell-interactive-mode-error-regexp'" (should (eq 0 (string-match-p haskell-interactive-mode-error-regexp "/home/user/Test.hs:24:30:"))) (should (eq 0 (string-match-p haskell-interactive-mode-error-regexp "Test.hs:5:18:"))) - (should (eq 0 (string-match-p - haskell-interactive-mode-error-regexp - "Test.hs:7:6: Not in scope: type constructor or class ‘Ty’"))) + (should (eq 0 (string-match-p haskell-interactive-mode-error-regexp + "Test.hs:7:6: Not in scope: type constructor or class ‘Ty’"))) (should (eq 0 (string-match-p haskell-interactive-mode-error-regexp "Test.hs:9:5: Not in scope: ‘c’"))) (should (eq nil (string-match-p haskell-interactive-mode-error-regexp ;; leading space " Test.hs:8:9:"))) ) - -(provide 'interactive-haskell-mode-tests) -;;; interactive-haskell-mode-tests.el ends here