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
1 changed files with 12 additions and 11 deletions

View File

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