Use temporary buffer for ghc-display

Instead of opening a normal editable buffer (in which editing text does
not make a lot of sense), use Emacs's temporary buffer. Benefits:

   - Read only: Text cannot be modified when focused.
   - Much easier to close (press q), after reading or copying from the
     warning/error.

Signed-off-by: Rohan Jain <crodjer@gmail.com>
This commit is contained in:
Rohan Jain 2014-04-06 21:50:38 +05:30 committed by Kazu Yamamoto
parent cc519edc98
commit a21178d2af

View File

@ -147,17 +147,18 @@
(defconst ghc-error-buffer-name "*GHC Info*") (defconst ghc-error-buffer-name "*GHC Info*")
(defun ghc-display (fontify ins-func) (defun ghc-display (fontify ins-func)
(let ((buf (get-buffer-create ghc-error-buffer-name))) (let ((buf ghc-error-buffer-name))
(with-current-buffer buf (with-output-to-temp-buffer buf
(erase-buffer) (with-current-buffer buf
(funcall ins-func) (erase-buffer)
(ghc-replace-character-buffer ghc-null ghc-newline) (funcall ins-func)
(goto-char (point-min)) (ghc-replace-character-buffer ghc-null ghc-newline)
(if (not fontify) (goto-char (point-min))
(turn-off-haskell-font-lock) (if (not fontify)
(haskell-font-lock-defaults-create) (turn-off-haskell-font-lock)
(turn-on-haskell-font-lock))) (haskell-font-lock-defaults-create)
(display-buffer buf))) (turn-on-haskell-font-lock)))
(display-buffer buf))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;