diff --git a/GHCMod.hs b/GHCMod.hs
--- a/GHCMod.hs
+++ b/GHCMod.hs
@@ -16,7 +16,7 @@
 ----------------------------------------------------------------
 
 usage :: String
-usage =    "ghc-mod version 0.4.0\n"
+usage =    "ghc-mod version 0.4.1\n"
         ++ "Usage:\n"
         ++ "\t ghc-mod list\n"
         ++ "\t ghc-mod lang\n"
diff --git a/elisp/Makefile b/elisp/Makefile
--- a/elisp/Makefile
+++ b/elisp/Makefile
@@ -1,10 +1,11 @@
-SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el
+SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el ghc-command.el
 EMACS = emacs
 
 TEMPFILE  = temp.el
 
 all: $(TEMPFILE) ghc.el
 	$(EMACS) -batch -q -no-site-file -l ./$(TEMPFILE) -f ghc-compile
+	rm -f $(TEMPFILE)
 
 $(TEMPFILE):
 	@echo '(setq load-path (cons "." load-path))' >> $(TEMPFILE)
diff --git a/elisp/ghc-command.el b/elisp/ghc-command.el
new file mode 100644
--- /dev/null
+++ b/elisp/ghc-command.el
@@ -0,0 +1,60 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; ghc-command.el
+;;;
+
+;; Author:  Kazu Yamamoto <Kazu@Mew.org>
+;; Created: Apr 13, 2010
+
+;;; Code:
+
+(provide 'ghc-flymake)
+
+(defun ghc-insert-template ()
+  (interactive)
+  (cond
+   ((bobp)
+    (ghc-insert-module-template))
+   ((save-excursion
+      (beginning-of-line)
+      (looking-at "^[^ ]+ *::"))
+    (ghc-insert-function-template))
+   ((ghc-flymake-have-errs-p)
+    (ghc-flymake-insert-from-warning))
+   (t
+    (message "Nothing to be done"))))
+
+(defun ghc-insert-module-template ()
+  ;; xxx mod from filename...
+  (let ((mod (file-name-sans-extension (buffer-name))))
+    (insert "module " mod " where\n")))
+
+(defun ghc-insert-function-template ()
+  (save-excursion
+    (beginning-of-line)
+    (when (looking-at "^\\([^ ]+\\) *::")
+      (save-match-data
+	(forward-line)
+	(if (eobp) (insert "\n")))
+      (insert (match-string 1) " = undefined\n"))))
+
+(defun ghc-sort-lines (beg end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (let ((inhibit-field-text-motion t))
+        (sort-subr nil 'forward-line 'end-of-line
+		   (lambda ()
+		     (re-search-forward "^import\\( *qualified\\)? *" nil t)
+		     nil)
+		   'end-of-line)))))
+
+(defun ghc-save-buffer ()
+  (interactive)
+  (if (buffer-modified-p)
+      (save-buffer)
+    (flymake-start-syntax-check)))
+
+(provide 'ghc-command)
diff --git a/ghc-mod.cabal b/ghc-mod.cabal
--- a/ghc-mod.cabal
+++ b/ghc-mod.cabal
@@ -1,5 +1,5 @@
 Name:                   ghc-mod
-Version:                0.4.0
+Version:                0.4.1
 Author:                 Kazu Yamamoto <kazu@iij.ad.jp>
 Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp>
 License:                BSD3
@@ -20,7 +20,7 @@
 Build-Type:             Simple
 Data-Dir:               elisp
 Data-Files:             Makefile ghc.el ghc-func.el ghc-doc.el ghc-comp.el
-                        ghc-flymake.el
+                        ghc-flymake.el ghc-command.el
 Executable ghc-mod
   Main-Is:              GHCMod.hs
   Other-Modules:        List Browse Check Lang Lint Types
