defining clear-overlay.

This commit is contained in:
Kazu Yamamoto 2012-02-15 11:20:24 +09:00
parent 952c255696
commit c51557b9bc

View File

@ -67,20 +67,21 @@
(defun ghc-type-init () (defun ghc-type-init ()
(setq ghc-type-overlay (make-overlay 0 0)) (setq ghc-type-overlay (make-overlay 0 0))
(overlay-put ghc-type-overlay 'face 'region) (overlay-put ghc-type-overlay 'face 'region)
(ghc-type-set-ix 0) (ghc-type-clear-overlay)
(ghc-type-set-point 0)
(setq after-change-functions (setq after-change-functions
(cons 'ghc-type-delete-overlay after-change-functions)) (cons 'ghc-type-clear-overlay after-change-functions))
(set (make-local-variable 'post-command-hook) 'ghc-type-post-command-hook)) (set (make-local-variable 'post-command-hook) 'ghc-type-post-command-hook))
(defun ghc-type-delete-overlay (&optional beg end len) (defun ghc-type-clear-overlay (&optional beg end len)
(when (overlayp ghc-type-overlay) (when (overlayp ghc-type-overlay)
(delete-overlay ghc-type-overlay))) (ghc-type-set-ix 0)
(ghc-type-set-point 0)
(move-overlay ghc-type-overlay 0 0)))
(defun ghc-type-post-command-hook () (defun ghc-type-post-command-hook ()
(when (and (overlayp ghc-type-overlay) (when (and (overlayp ghc-type-overlay)
(/= (ghc-type-get-point) (point))) (/= (ghc-type-get-point) (point)))
(ghc-type-delete-overlay))) (ghc-type-clear-overlay)))
(defun ghc-show-type () (defun ghc-show-type ()
(interactive) (interactive)
@ -95,7 +96,9 @@
(let* ((buf (current-buffer)) (let* ((buf (current-buffer))
(tinfos (ghc-type-get-tinfos modname))) (tinfos (ghc-type-get-tinfos modname)))
(if (null tinfos) (if (null tinfos)
(message "Cannot guess type") (progn
(ghc-type-clear-overlay)
(message "Cannot guess type"))
(let* ((tinfo (nth (ghc-type-get-ix) tinfos)) (let* ((tinfo (nth (ghc-type-get-ix) tinfos))
(type (ghc-tinfo-get-info tinfo)) (type (ghc-tinfo-get-info tinfo))
(beg-line (ghc-tinfo-get-beg-line tinfo)) (beg-line (ghc-tinfo-get-beg-line tinfo))