magical module name.
This commit is contained in:
parent
97b3de7328
commit
ce87ab328a
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'ghc-process)
|
||||||
(require 'ghc-check)
|
(require 'ghc-check)
|
||||||
|
|
||||||
(defun ghc-insert-template ()
|
(defun ghc-insert-template ()
|
||||||
@ -21,10 +22,24 @@
|
|||||||
(message "Nothing to be done"))))
|
(message "Nothing to be done"))))
|
||||||
|
|
||||||
(defun ghc-insert-module-template ()
|
(defun ghc-insert-module-template ()
|
||||||
(let ((mod (file-name-sans-extension (buffer-name))))
|
(let* ((fullname (file-name-sans-extension (buffer-file-name)))
|
||||||
(aset mod 0 (upcase (aref mod 0)))
|
(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")))
|
(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)
|
(defun ghc-sort-lines (beg end)
|
||||||
(interactive "r")
|
(interactive "r")
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defun ghc-get-process-name ()
|
(defun ghc-get-project-root ()
|
||||||
(let ((file (buffer-file-name)))
|
(let ((file (buffer-file-name)))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(ghc-call-process ghc-module-command nil t nil "root" file)
|
(ghc-call-process ghc-module-command nil t nil "root" file)
|
||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
(defun ghc-with-process (send callback)
|
(defun ghc-with-process (send callback)
|
||||||
(unless ghc-process-process-name
|
(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
|
(when ghc-process-process-name
|
||||||
(let* ((cbuf (current-buffer))
|
(let* ((cbuf (current-buffer))
|
||||||
(name ghc-process-process-name)
|
(name ghc-process-process-name)
|
||||||
|
Loading…
Reference in New Issue
Block a user