defining "info" for "ESC i".
This commit is contained in:
@@ -10,14 +10,35 @@
|
||||
|
||||
(require 'ghc-func)
|
||||
|
||||
(defun ghc-show-type ()
|
||||
(interactive)
|
||||
(defun ghc-show-type (&optional ask)
|
||||
(interactive "P")
|
||||
(if (not (ghc-which ghc-module-command))
|
||||
(message "%s not found" ghc-module-command)
|
||||
(let ((expr (thing-at-point 'symbol))
|
||||
(file (buffer-name)))
|
||||
(let* ((expr0 (thing-at-point 'symbol))
|
||||
(expr (if ask (ghc-read-expression expr0) expr0))
|
||||
(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))))))))
|
||||
|
||||
(defun ghc-show-info (&optional ask)
|
||||
(interactive "P")
|
||||
(if (not (ghc-which ghc-module-command))
|
||||
(message "%s not found" ghc-module-command)
|
||||
(let* ((expr0 (thing-at-point 'symbol))
|
||||
(expr (if ask (ghc-read-expression expr0) expr0))
|
||||
(file (buffer-name))
|
||||
(buf (get-buffer-create ghc-error-buffer-name)))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(insert
|
||||
(with-temp-buffer
|
||||
(call-process ghc-module-command nil t nil "info" file expr)
|
||||
(buffer-substring (point-min) (1- (point-max))))))
|
||||
(display-buffer buf))))
|
||||
|
||||
(defun ghc-read-expression (default)
|
||||
(let ((prompt (format "Expression (%s): " default)))
|
||||
(read-string prompt default nil)))
|
||||
|
||||
(provide 'ghc-info)
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
(defvar ghc-help-key "\e?")
|
||||
(defvar ghc-insert-key "\et")
|
||||
(defvar ghc-sort-key "\es")
|
||||
(defvar ghc-type-key "\e\C-t")
|
||||
(defvar ghc-type-key "\ek")
|
||||
(defvar ghc-info-key "\ei")
|
||||
(defvar ghc-check-key "\C-x\C-s")
|
||||
(defvar ghc-toggle-key "\C-c\C-c")
|
||||
|
||||
@@ -58,6 +59,7 @@
|
||||
(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-info-key 'ghc-show-info)
|
||||
(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)
|
||||
|
||||
Reference in New Issue
Block a user