Skip to content

Commit 0d3a8d8

Browse files
committed
Merge pull request #1003 from bergey/do-not-sort-imports-twice
Do not sort imports twice
2 parents 1d9d2f3 + ab1ec6a commit 0d3a8d8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

haskell-customize.el

+7
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ same vein as `haskell-indent-spaces'."
404404
:group 'haskell
405405
:type '(repeat 'string))
406406

407+
;;;###autoload
408+
(defcustom haskell-stylish-on-save nil
409+
"Whether to run stylish-haskell on the buffer before saving.
410+
If this is true, `haskell-add-import' will not sort or align the
411+
imports."
412+
:group 'haskell
413+
:type 'boolean)
407414

408415
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
409416
;; Accessor functions

haskell-mode.el

-6
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,6 @@ Note that negative arguments do not work so well."
820820
(const "ghc -fno-code")
821821
(string :tag "Other command")))
822822

823-
;;;###autoload
824-
(defcustom haskell-stylish-on-save nil
825-
"Whether to run stylish-haskell on the buffer before saving."
826-
:group 'haskell
827-
:type 'boolean)
828-
829823
;;;###autoload
830824
(defcustom haskell-tags-on-save nil
831825
"Generate tags via hasktags after saving."

haskell-modules.el

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
(require 'haskell-navigate-imports)
2424
(require 'haskell-complete-module)
2525
(require 'haskell-sandbox)
26+
(require 'haskell-customize)
2627

2728
(defun haskell-add-import (&optional module)
28-
"Add an import to the import list."
29+
"Add an import to the import list. Sorts and aligns imports,
30+
unless `haskell-stylish-on-save' is set, in which case we defer
31+
to stylish-haskell."
2932
(interactive)
3033
(save-excursion
3134
(goto-char (point-max))
@@ -35,8 +38,8 @@
3538
(haskell-complete-module-read
3639
"Module: "
3740
(haskell-session-all-modules (haskell-modules-session))))))
38-
(haskell-sort-imports)
39-
(haskell-align-imports)))
41+
(unless haskell-stylish-on-save (haskell-sort-imports)
42+
(haskell-align-imports))))
4043

4144
(defun haskell-import-for-module (module)
4245
"Get import statements for the given module."

0 commit comments

Comments
 (0)