Permalink
Browse files

Print a proper error if inferior-haskell-load-file is called on a buf…

…fer without an associated file

Ignore-this: 4fd28c28bfdd513c5069a8c26cf6e74b

darcs-hash:20100702103625-f57bf-05c979caea6873700e5e7a6b60350e34a1fbd88f.gz
  • Loading branch information...
1 parent 2e3b760 commit 2702f778db016981a51fa59c86d556d5ec77e745 @Baughn Baughn committed Jul 2, 2010
Showing with 39 additions and 37 deletions.
  1. +39 −37 inf-haskell.el
View
@@ -319,44 +319,46 @@ If prefix arg \\[universal-argument] is given, just reload the previous file."
(let ((buf (current-buffer))
(file buffer-file-name)
(proc (inferior-haskell-process)))
- (with-current-buffer (process-buffer proc)
- (compilation-forget-errors)
- (let ((parsing-end (marker-position (process-mark proc)))
- root)
- ;; Go to the root of the Cabal project, if applicable.
- (when (and inferior-haskell-find-project-root
- (setq root (inferior-haskell-find-project-root buf)))
- ;; Not sure if it's useful/needed and if it actually works.
- (unless (equal default-directory root)
- (setq default-directory root)
+ (if file
+ (with-current-buffer (process-buffer proc)
+ (compilation-forget-errors)
+ (let ((parsing-end (marker-position (process-mark proc)))
+ root)
+ ;; Go to the root of the Cabal project, if applicable.
+ (when (and inferior-haskell-find-project-root
+ (setq root (inferior-haskell-find-project-root buf)))
+ ;; Not sure if it's useful/needed and if it actually works.
+ (unless (equal default-directory root)
+ (setq default-directory root)
+ (inferior-haskell-send-command
+ proc (concat ":cd " default-directory)))
+ (setq file (file-relative-name file)))
(inferior-haskell-send-command
- proc (concat ":cd " default-directory)))
- (setq file (file-relative-name file)))
- (inferior-haskell-send-command
- proc (if reload ":reload"
- (concat ":load \""
- ;; Espace the backslashes that may occur in file names.
- (replace-regexp-in-string "[\\\"]" "\\\\\&" file)
- "\"")))
- ;; Move the parsing-end marker *after* sending the command so
- ;; that it doesn't point just to the insertion point.
- ;; Otherwise insertion may move the marker (if done with
- ;; insert-before-markers) and we'd then miss some errors.
- (if (boundp 'compilation-parsing-end)
- (if (markerp compilation-parsing-end)
- (set-marker compilation-parsing-end parsing-end)
- (setq compilation-parsing-end parsing-end))))
- (with-selected-window (display-buffer (current-buffer) nil 'visible)
- (goto-char (point-max)))
- ;; Use compilation-auto-jump-to-first-error if available.
- ;; (if (and (boundp 'compilation-auto-jump-to-first-error)
- ;; compilation-auto-jump-to-first-error
- ;; (boundp 'compilation-auto-jump-to-next))
- ;; (setq compilation-auto-jump-to-next t)
- (when inferior-haskell-wait-and-jump
- (inferior-haskell-wait-for-prompt proc)
- (ignore-errors ;Don't beep if there were no errors.
- (next-error)))))) ;; )
+ proc (if reload ":reload"
+ (concat ":load \""
+ ;; Espace the backslashes that may occur in file names.
+ (replace-regexp-in-string "[\\\"]" "\\\\\&" file)
+ "\"")))
+ ;; Move the parsing-end marker *after* sending the command so
+ ;; that it doesn't point just to the insertion point.
+ ;; Otherwise insertion may move the marker (if done with
+ ;; insert-before-markers) and we'd then miss some errors.
+ (if (boundp 'compilation-parsing-end)
+ (if (markerp compilation-parsing-end)
+ (set-marker compilation-parsing-end parsing-end)
+ (setq compilation-parsing-end parsing-end))))
+ (with-selected-window (display-buffer (current-buffer) nil 'visible)
+ (goto-char (point-max)))
+ ;; Use compilation-auto-jump-to-first-error if available.
+ ;; (if (and (boundp 'compilation-auto-jump-to-first-error)
+ ;; compilation-auto-jump-to-first-error
+ ;; (boundp 'compilation-auto-jump-to-next))
+ ;; (setq compilation-auto-jump-to-next t)
+ (when inferior-haskell-wait-and-jump
+ (inferior-haskell-wait-for-prompt proc)
+ (ignore-errors ;Don't beep if there were no errors.
+ (next-error))))
+ (error "No file associated with buffer"))))
(defvar inferior-haskell-run-command ":main")

0 comments on commit 2702f77

Please sign in to comment.