ghc-expand-th.
This commit is contained in:
parent
3f2771a079
commit
6aea177fcb
@ -12,26 +12,12 @@
|
||||
|
||||
(defun ghc-show-info (&optional ask)
|
||||
(interactive "P")
|
||||
(if (not (ghc-which ghc-module-command))
|
||||
(message "%s not found" ghc-module-command)
|
||||
(let ((modname (or (ghc-find-module-name) "Main")))
|
||||
(ghc-show-info0 ask modname))))
|
||||
|
||||
(defun ghc-show-info0 (ask modname)
|
||||
(let* ((expr0 (ghc-things-at-point))
|
||||
(let* ((modname (or (ghc-find-module-name) "Main"))
|
||||
(expr0 (ghc-things-at-point))
|
||||
(expr (if ask (ghc-read-expression expr0) expr0))
|
||||
(cdir default-directory)
|
||||
(file (buffer-file-name))
|
||||
(buf (get-buffer-create ghc-error-buffer-name)))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(insert
|
||||
(with-temp-buffer
|
||||
(cd cdir)
|
||||
(apply 'call-process ghc-module-command nil t nil
|
||||
`(,@(ghc-make-ghc-options) "info" ,file ,modname ,expr))
|
||||
(buffer-substring (point-min) (1- (point-max))))))
|
||||
(display-buffer buf)))
|
||||
(cmds (list "info" file modname expr)))
|
||||
(ghc-display-information cmds)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
@ -129,6 +115,41 @@
|
||||
(while (search-forward "[Char]" nil t)
|
||||
(replace-match "String"))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Expanding Template Haskell
|
||||
;;;
|
||||
|
||||
(defun ghc-expand-th ()
|
||||
(interactive)
|
||||
(let* ((file (buffer-file-name))
|
||||
(cmds (list "expand" file)))
|
||||
(ghc-display-information cmds)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Display
|
||||
;;;
|
||||
|
||||
(defun ghc-display-information (cmds)
|
||||
(interactive)
|
||||
(if (not (ghc-which ghc-module-command))
|
||||
(message "%s not found" ghc-module-command)
|
||||
(let ((cdir default-directory)
|
||||
(buf (get-buffer-create ghc-error-buffer-name)))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(insert
|
||||
(with-temp-buffer
|
||||
(cd cdir)
|
||||
(apply 'call-process ghc-module-command nil t nil
|
||||
(append (ghc-make-ghc-options) cmds))
|
||||
(buffer-substring (point-min) (1- (point-max)))))
|
||||
(goto-char (point-min))
|
||||
(haskell-font-lock-defaults-create)
|
||||
(turn-on-haskell-font-lock))
|
||||
(display-buffer buf))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Misc
|
||||
|
@ -52,6 +52,7 @@
|
||||
(defvar ghc-check-key "\C-x\C-s")
|
||||
(defvar ghc-toggle-key "\C-c\C-c")
|
||||
(defvar ghc-module-key "\C-c\C-m")
|
||||
(defvar ghc-expand-key "\C-c\C-e")
|
||||
(defvar ghc-hoogle-key (format "\C-c%c" (ghc-find-C-h)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -70,6 +71,7 @@
|
||||
(define-key haskell-mode-map ghc-document-key 'ghc-browse-document)
|
||||
(define-key haskell-mode-map ghc-type-key 'ghc-show-type)
|
||||
(define-key haskell-mode-map ghc-info-key 'ghc-show-info)
|
||||
(define-key haskell-mode-map ghc-expand-key 'ghc-expand-th)
|
||||
(define-key haskell-mode-map ghc-import-key 'ghc-import-module)
|
||||
(define-key haskell-mode-map ghc-previous-key 'flymake-goto-prev-error)
|
||||
(define-key haskell-mode-map ghc-next-key 'flymake-goto-next-error)
|
||||
|
Loading…
Reference in New Issue
Block a user