Skip to content

Commit db967b9

Browse files
committed
Merge branch '462-module-template' of https://github.com/MichaelXavier/haskell-mode
2 parents 2b0d478 + f3c6724 commit db967b9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

haskell-mode.el

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,27 +1033,19 @@ LOC = (list FILE LINE COL)"
10331033
collect (replace-regexp-in-string "\\.l?hs$" "" part))))
10341034
(mapconcat 'identity (reverse components) ".")))
10351035

1036+
(defvar haskell-auto-insert-module-format-string
1037+
"-- | \n\nmodule %s where\n\n"
1038+
"Template string that will be inserted in new haskell buffers via `haskell-auto-insert-module-template'.")
1039+
10361040
(defun haskell-auto-insert-module-template ()
10371041
"Insert a module template for the newly created buffer."
10381042
(interactive)
10391043
(when (and (= (point-min)
10401044
(point-max))
10411045
(buffer-file-name))
1042-
(insert
1043-
"-- | "
1044-
"\n"
1045-
"\n"
1046-
"module "
1047-
)
1048-
(let ((name (haskell-guess-module-name)))
1049-
(if (string= name "")
1050-
(insert "")
1051-
(insert name)))
1052-
(insert " where"
1053-
"\n"
1054-
"\n")
1046+
(insert (format haskell-auto-insert-module-format-string (haskell-guess-module-name)))
10551047
(goto-char (point-min))
1056-
(forward-char 4)))
1048+
(end-of-line)))
10571049

10581050

10591051
;; Provide ourselves:

0 commit comments

Comments
 (0)