Skip to content

Do not sort imports twice #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions haskell-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ same vein as `haskell-indent-spaces'."
:group 'haskell
:type '(repeat 'string))

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Accessor functions
Expand Down
6 changes: 0 additions & 6 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,6 @@ Note that negative arguments do not work so well."
(const "ghc -fno-code")
(string :tag "Other command")))

;;;###autoload
(defcustom haskell-stylish-on-save nil
"Whether to run stylish-haskell on the buffer before saving."
:group 'haskell
:type 'boolean)

;;;###autoload
(defcustom haskell-tags-on-save nil
"Generate tags via hasktags after saving."
Expand Down
9 changes: 6 additions & 3 deletions haskell-modules.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
(require 'haskell-navigate-imports)
(require 'haskell-complete-module)
(require 'haskell-sandbox)
(require 'haskell-customize)

(defun haskell-add-import (&optional module)
"Add an import to the import list."
"Add an import to the import list. Sorts and aligns imports,
unless `haskell-stylish-on-save' is set, in which case we defer
to stylish-haskell."
(interactive)
(save-excursion
(goto-char (point-max))
Expand All @@ -35,8 +38,8 @@
(haskell-complete-module-read
"Module: "
(haskell-session-all-modules (haskell-modules-session))))))
(haskell-sort-imports)
(haskell-align-imports)))
(unless haskell-stylish-on-save (haskell-sort-imports)
(haskell-align-imports))))

(defun haskell-import-for-module (module)
"Get import statements for the given module."
Expand Down