diff --git a/elisp/Makefile b/elisp/Makefile index 0781feb..598b11e 100644 --- a/elisp/Makefile +++ b/elisp/Makefile @@ -1,4 +1,5 @@ -SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el ghc-command.el +SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el \ + ghc-command.el ghc-info.el EMACS = emacs TEMPFILE = temp.el diff --git a/elisp/ghc-info.el b/elisp/ghc-info.el new file mode 100644 index 0000000..73f2b94 --- /dev/null +++ b/elisp/ghc-info.el @@ -0,0 +1,23 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; ghc-info.el +;;; + +;; Author: Kazu Yamamoto +;; Created: Nov 15, 2010 + +;;; Code: + +(require 'ghc-func) + +(defun ghc-show-type () + (interactive) + (if (not (ghc-which ghc-module-command)) + (message "%s not found" ghc-module-command) + (let ((expr (thing-at-point 'symbol)) + (file (buffer-name))) + (with-temp-buffer + (call-process ghc-module-command nil t nil "type" file expr) + (message (buffer-substring (point-min) (1- (point-max)))))))) + +(provide 'ghc-info) diff --git a/elisp/ghc.el b/elisp/ghc.el index 15fd07f..fe0157e 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -23,6 +23,7 @@ (require 'ghc-comp) (require 'ghc-doc) +(require 'ghc-info) (require 'ghc-flymake) (require 'ghc-command) (require 'dabbrev) @@ -40,6 +41,7 @@ (defvar ghc-help-key "\e?") (defvar ghc-insert-key "\et") (defvar ghc-sort-key "\es") +(defvar ghc-type-key "\e\C-t") (defvar ghc-check-key "\C-x\C-s") (defvar ghc-toggle-key "\C-c\C-c") @@ -55,6 +57,7 @@ (unless ghc-initialized (define-key haskell-mode-map ghc-completion-key 'ghc-complete) (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-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)