ghc-mod/elisp/ghc-command.el

47 lines
1.1 KiB
EmacsLisp
Raw Normal View History

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; ghc-command.el
;;;
;; Author: Kazu Yamamoto <Kazu@Mew.org>
;; Created: Apr 13, 2010
;;; Code:
(require 'ghc-check)
(defun ghc-insert-template ()
(interactive)
(cond
((bobp)
(ghc-insert-module-template))
;; ((ghc-flymake-have-errs-p) ;; fixme
;; (ghc-flymake-insert-from-warning))
(t
(message "Nothing to be done"))))
(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)))
(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)))))
(defun ghc-save-buffer ()
(interactive)
2014-03-20 06:32:54 +00:00
(if (buffer-modified-p) (call-interactively 'save-buffer))
(ghc-check-syntax))
(provide 'ghc-command)