Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
elisp: deinit ghc-type and ghc-check properly
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielG committed Sep 18, 2016
1 parent f53dddb commit 3a9c510
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion elisp/ghc-check.el
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ open this file and jump to the error inside it."
'ghc-check-callback
(lambda () (setq mode-line-process " -:-")))))


(defun ghc-check-deinit ()
(ghc-kill-process)
(remove-overlays (point-min) (point-max) 'ghc-check t))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(ghc-defstruct msg-info file line coln msg type)
Expand Down Expand Up @@ -127,7 +132,7 @@ open this file and jump to the error inside it."
(ghc-with-current-buffer ghc-process-original-buffer
(let ((len (length infos)))
(if (= len 0)
(setq mode-line-process "")
(setq mode-line-process nil)
(let* ((errs (ghc-filter (lambda (info) (eq 'err (ghc-msg-info-get-type info))) infos))
(elen (length errs))
(wlen (- len elen)))
Expand Down
5 changes: 3 additions & 2 deletions elisp/ghc-info.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ expression who's type was just analyzed.")

(defun ghc-type-init ()
(setq ghc-type-overlay (make-overlay 0 0))
(overlay-put ghc-type-overlay 'ghc-type t)
(overlay-put ghc-type-overlay 'face 'region)
(ghc-type-clear-overlay)
(setq after-change-functions
Expand All @@ -67,8 +68,8 @@ expression who's type was just analyzed.")
(remove-hook 'post-command-hook 'ghc-type-post-command-hook)
(setq after-change-functions
(delq 'ghc-type-clear-overlay after-change-functions))
;; TODO: remember buffers where overlays were created and clear them on deinit
(ghc-type-clear-overlay) )
(ghc-type-clear-overlay)
(remove-overlays (point-min) (point-max) 'ghc-type t))

(defun ghc-type-clear-overlay (&optional _beg _end _len)
(when (overlayp ghc-type-overlay)
Expand Down
3 changes: 2 additions & 1 deletion elisp/ghc-process.el
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
(if (not cpro)
(message "No ghc-mod process")
(delete-process cpro)
(message "ghc-mod process was killed")))))
(message "ghc-mod process was killed")))
(setq mode-line-process nil)))

(provide 'ghc-process)
1 change: 1 addition & 0 deletions elisp/ghc.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ deprecated. Use `define-key' in `ghc-mode-hook' instead.")

(defun ghc-mod-deinit ()
(ad-disable-advice 'save-buffer 'after 'ghc-mod-check-syntax-on-save)
(ghc-check-deinit)
(ghc-comp-deinit)
(ghc-type-deinit)
(ghc-abbrev-deinit)
Expand Down

0 comments on commit 3a9c510

Please sign in to comment.