Skip to content

Commit b6871d1

Browse files
committed
compat for stylish-haskell & haskell-add-import
If `haskell-stylish-on-save` is set, assume that stylish-haskell is handling import alignment & sorting. Therefore, do not align and sort after inserting a new import with `haskell-add-import`. Add documentation explaining this to both `haskell-stylish-on-save` and `haskell-add-import`. closes #914
1 parent 1d9d2f3 commit b6871d1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

haskell-mode.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ Note that negative arguments do not work so well."
822822

823823
;;;###autoload
824824
(defcustom haskell-stylish-on-save nil
825-
"Whether to run stylish-haskell on the buffer before saving."
825+
"Whether to run stylish-haskell on the buffer before saving.
826+
If this is true, `haskell-add-import' will not sort or align the
827+
imports."
826828
:group 'haskell
827829
:type 'boolean)
828830

haskell-modules.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
(require 'haskell-sandbox)
2626

2727
(defun haskell-add-import (&optional module)
28-
"Add an import to the import list."
28+
"Add an import to the import list. Sorts and aligns imports,
29+
unless `haskell-stylish-on-save' is set, in which case we defer
30+
to stylish-haskell."
2931
(interactive)
3032
(save-excursion
3133
(goto-char (point-max))
@@ -35,8 +37,8 @@
3537
(haskell-complete-module-read
3638
"Module: "
3739
(haskell-session-all-modules (haskell-modules-session))))))
38-
(haskell-sort-imports)
39-
(haskell-align-imports)))
40+
(unless haskell-stylish-on-save (haskell-sort-imports)
41+
(haskell-align-imports))))
4042

4143
(defun haskell-import-for-module (module)
4244
"Get import statements for the given module."

0 commit comments

Comments
 (0)