magical module name.
This commit is contained in:
parent
97b3de7328
commit
ce87ab328a
@ -8,6 +8,7 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ghc-process)
|
||||
(require 'ghc-check)
|
||||
|
||||
(defun ghc-insert-template ()
|
||||
@ -21,10 +22,24 @@
|
||||
(message "Nothing to be done"))))
|
||||
|
||||
(defun ghc-insert-module-template ()
|
||||
(let ((mod (file-name-sans-extension (buffer-name))))
|
||||
(aset mod 0 (upcase (aref mod 0)))
|
||||
(let* ((fullname (file-name-sans-extension (buffer-file-name)))
|
||||
(rootdir (ghc-get-project-root))
|
||||
(len (length rootdir))
|
||||
(name (substring fullname (1+ len)))
|
||||
(file (file-name-sans-extension (buffer-name)))
|
||||
(case-fold-search nil)
|
||||
(mod (if (string-match "^[A-Z]" name)
|
||||
(ghc-replace-character name ?/ ?.)
|
||||
(if (string-match "^[a-z]" file)
|
||||
"Main"
|
||||
file))))
|
||||
(insert "module " mod " where\n")))
|
||||
|
||||
;; (defun ghc-capitalize (str)
|
||||
;; (let ((ret (copy-sequence str)))
|
||||
;; (aset ret 0 (upcase (aref ret 0)))
|
||||
;; ret))
|
||||
|
||||
(defun ghc-sort-lines (beg end)
|
||||
(interactive "r")
|
||||
(save-excursion
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun ghc-get-process-name ()
|
||||
(defun ghc-get-project-root ()
|
||||
(let ((file (buffer-file-name)))
|
||||
(with-temp-buffer
|
||||
(ghc-call-process ghc-module-command nil t nil "root" file)
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
(defun ghc-with-process (send callback)
|
||||
(unless ghc-process-process-name
|
||||
(setq ghc-process-process-name (ghc-get-process-name)))
|
||||
(setq ghc-process-process-name (ghc-get-project-root)))
|
||||
(when ghc-process-process-name
|
||||
(let* ((cbuf (current-buffer))
|
||||
(name ghc-process-process-name)
|
||||
|
Loading…
Reference in New Issue
Block a user