M-C-t for showing type.

This commit is contained in:
Kazu Yamamoto 2010-11-15 12:46:55 +09:00
parent 537d825668
commit 30924fa26d
3 changed files with 28 additions and 1 deletions

View File

@ -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

23
elisp/ghc-info.el Normal file
View File

@ -0,0 +1,23 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; ghc-info.el
;;;
;; Author: Kazu Yamamoto <Kazu@Mew.org>
;; 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)

View File

@ -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)