Skip to content

Commit

Permalink
Support commenting out of imports
Browse files Browse the repository at this point in the history
When GHC suggests redundant imports, the question and answers are now:

The import line `Foo' is redundant. Remove?

- y: yes, remove
- n: no, don't remove
- c: comment out the line

This is handy for easily adding back imports when they become relevant
again.

@hvr Might be of interest.
  • Loading branch information
chrisdone committed Jan 15, 2014
1 parent dc3a02f commit f13eae5
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions haskell-process.el
Original file line number Diff line number Diff line change
Expand Up @@ -659,14 +659,25 @@ from `module-buffer'."
(haskell-process-suggest-pragma session "LANGUAGE" "OverloadedStrings" file)))))

(defun haskell-process-suggest-remove-import (session file import line)
(when (y-or-n-p (format "The import line `%s' is redundant. Remove? " import))
(haskell-process-find-file session file)
(save-excursion
(goto-char (point-min))
(forward-line (1- line))
(goto-char (line-beginning-position))
(delete-region (line-beginning-position)
(line-end-position)))))
"Suggest removing or commenting out IMPORT on LINE."
(case (read-key (propertize (format "The import line `%s' is redundant. Remove? (y, n, c: comment out) "
import)
'face 'minibuffer-prompt))
(?y
(haskell-process-find-file session file)
(save-excursion
(goto-char (point-min))
(forward-line (1- line))
(goto-char (line-beginning-position))
(delete-region (line-beginning-position)
(line-end-position))))
(?c
(haskell-process-find-file session file)
(save-excursion
(goto-char (point-min))
(forward-line (1- line))
(goto-char (line-beginning-position))
(insert "-- ")))))

(defun haskell-process-suggest-pragma (session pragma extension file)
"Suggest to add something to the top of the file."
Expand Down

0 comments on commit f13eae5

Please sign in to comment.