2010-04-13 14:29:48 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;
|
|
|
|
;;; ghc-command.el
|
|
|
|
;;;
|
|
|
|
|
|
|
|
;; Author: Kazu Yamamoto <Kazu@Mew.org>
|
|
|
|
;; Created: Apr 13, 2010
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2010-05-12 06:00:08 +00:00
|
|
|
(require 'ghc-flymake)
|
2010-04-13 14:29:48 +00:00
|
|
|
|
|
|
|
(defun ghc-insert-template ()
|
|
|
|
(interactive)
|
|
|
|
(cond
|
|
|
|
((bobp)
|
|
|
|
(ghc-insert-module-template))
|
2010-06-14 05:26:14 +00:00
|
|
|
((ghc-flymake-have-errs-p)
|
|
|
|
(ghc-flymake-insert-from-warning))
|
2010-04-13 14:29:48 +00:00
|
|
|
(t
|
2010-05-04 03:14:33 +00:00
|
|
|
(message "Nothing to be done"))))
|
2010-04-13 14:29:48 +00:00
|
|
|
|
|
|
|
(defun ghc-insert-module-template ()
|
2011-12-26 07:27:55 +00:00
|
|
|
(let ((mod (file-name-sans-extension (buffer-name))))
|
|
|
|
(aset mod 0 (upcase (aref mod 0)))
|
2010-04-13 14:29:48 +00:00
|
|
|
(insert "module " mod " where\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)))))
|
|
|
|
|
2010-04-23 09:38:11 +00:00
|
|
|
(defun ghc-save-buffer ()
|
|
|
|
(interactive)
|
|
|
|
(if (buffer-modified-p)
|
2012-08-03 03:44:28 +00:00
|
|
|
(call-interactively 'save-buffer)
|
2010-04-23 09:38:11 +00:00
|
|
|
(flymake-start-syntax-check)))
|
|
|
|
|
2010-04-13 14:29:48 +00:00
|
|
|
(provide 'ghc-command)
|