checking if the buffer exists (#256).

This commit is contained in:
Kazu Yamamoto 2014-05-14 05:05:49 +09:00
parent e9f38f10a2
commit ce28a67e28
3 changed files with 15 additions and 7 deletions

View File

@ -80,9 +80,9 @@ nil does not display errors/warnings.
(buf ghc-process-original-buffer))
(ghc-check-highlight-original-buffer file buf infos)))
(t
(with-current-buffer ghc-process-original-buffer
(ghc-with-current-buffer ghc-process-original-buffer
(remove-overlays (point-min) (point-max) 'ghc-check t))))
(with-current-buffer ghc-process-original-buffer
(ghc-with-current-buffer ghc-process-original-buffer
(let ((len (length infos)))
(if (= len 0)
(setq mode-line-process "")
@ -91,7 +91,7 @@ nil does not display errors/warnings.
(wlen (- len elen)))
(setq mode-line-process (format " %d:%d" elen wlen))))))))
(t
(with-current-buffer ghc-process-original-buffer
(ghc-with-current-buffer ghc-process-original-buffer
(setq mode-line-process " failed")))))
(defun ghc-to-info (errs)
@ -114,7 +114,7 @@ nil does not display errors/warnings.
(ghc-add infos info)))))))
(defun ghc-check-highlight-original-buffer (ofile buf infos)
(with-current-buffer buf
(ghc-with-current-buffer buf
(remove-overlays (point-min) (point-max) 'ghc-check t)
(save-excursion
(goto-char (point-min))

View File

@ -205,4 +205,12 @@
expr
(concat "(" expr ")"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro ghc-with-current-buffer (buf &rest body)
;; (declare (indent 1))
`(if (get-buffer ,buf)
(with-current-buffer ,buf
,@body)))
(provide 'ghc-func)

View File

@ -36,7 +36,7 @@
(buf (get-buffer-create (concat " ghc-modi:" name)))
(file (buffer-file-name))
(cpro (get-process name)))
(with-current-buffer buf
(ghc-with-current-buffer buf
(unless ghc-process-running
(setq ghc-process-running t)
(setq ghc-process-original-buffer cbuf)
@ -69,7 +69,7 @@
pro))
(defun ghc-process-filter (process string)
(with-current-buffer (process-buffer process)
(ghc-with-current-buffer (process-buffer process)
(goto-char (point-max))
(insert string)
(forward-line -1)
@ -110,7 +110,7 @@
;; (discard-input) avoids getting stuck.
(discard-input))
(quit
(with-current-buffer (process-buffer pro)
(ghc-with-current-buffer (process-buffer pro)
(setq ghc-process-running nil)))))
ghc-process-results)