Permalink
Browse files

(inferior-haskell-spot-prompt): New function.

Ignore-this: 7bdb9469e138f16be3a64a7eb535ad6f
(inferior-haskell-spot-prompt): New function.
(inferior-haskell-mode): Use it.
(inferior-haskell-seen-prompt): New var.
(inferior-haskell-wait-for-prompt): Use it.
(inferior-haskell-send-command): Reset it.
(inferior-haskell-type): Avoid use of remove-it.

darcs-hash:20080513042517-c2f2e-72fea7667b57ba1e3bc3179260767a315fdd9c24.gz
  • Loading branch information...
1 parent 947a32d commit ce971bbd3e4001854a1f30b20434805ae7f113dc monnier committed May 13, 2008
Showing with 31 additions and 9 deletions.
  1. +7 −0 ChangeLog
  2. +24 −9 inf-haskell.el
View
@@ -1,5 +1,12 @@
2008-05-12 Stefan Monnier <monnier@iro.umontreal.ca>
+ * inf-haskell.el (inferior-haskell-spot-prompt): New function.
+ (inferior-haskell-mode): Use it.
+ (inferior-haskell-seen-prompt): New var.
+ (inferior-haskell-wait-for-prompt): Use it.
+ (inferior-haskell-send-command): Reset it.
+ (inferior-haskell-type): Avoid use of remove-it.
+
* inf-haskell.el (inferior-haskell-info-xref-re): Allow a column-range.
Reported by Jose A. Ortega Ruiz <jao@google.com>.
(inferior-haskell-error-regexp-alist): Use the extra column-end info
View
@@ -125,6 +125,7 @@ This will either look for a Cabal file or a \"module\" statement in the file."
(set (make-local-variable 'comint-prompt-regexp)
"^\\*?[A-Z][\\._a-zA-Z0-9]*\\( \\*?[A-Z][\\._a-zA-Z0-9]*\\)*> ")
(set (make-local-variable 'comint-input-autoexpand) nil)
+ (add-hook 'comint-output-filter-functions 'inferior-haskell-spot-prompt nil t)
;; Setup directory tracking.
(set (make-local-variable 'shell-cd-regexp) ":cd")
@@ -216,17 +217,30 @@ setting up the inferior-haskell buffer."
:type 'boolean
:group 'haskell)
+(defvar inferior-haskell-seen-prompt nil)
+(make-variable-buffer-local 'inferior-haskell-seen-prompt)
+
+(defun inferior-haskell-spot-prompt (string)
+ (let ((proc (get-buffer-process (current-buffer))))
+ (when proc
+ (save-excursion
+ (goto-char (process-mark proc))
+ (if (re-search-backward comint-prompt-regexp
+ (line-beginning-position) t)
+ (setq inferior-haskell-seen-prompt t))))))
+
(defun inferior-haskell-wait-for-prompt (proc &optional timeout)
"Wait until PROC sends us a prompt.
The process PROC should be associated to a comint buffer."
(with-current-buffer (process-buffer proc)
- (let ((found nil))
- (while (progn
- (goto-char comint-last-input-end)
- (and (not (setq found
- (re-search-forward comint-prompt-regexp nil t)))
- (accept-process-output proc timeout))))
- (unless found (error "Can't find the prompt.")))))
+ (while (progn
+ (goto-char comint-last-input-end)
+ (not (or inferior-haskell-seen-prompt
+ (setq inferior-haskell-seen-prompt
+ (re-search-forward comint-prompt-regexp nil t))
+ (not (accept-process-output proc timeout))))))
+ (unless inferior-haskell-seen-prompt
+ (error "Can't find the prompt."))))
(defvar inferior-haskell-cabal-buffer nil)
@@ -355,6 +369,7 @@ If prefix arg \\[universal-argument] is given, just reload the previous file."
(goto-char (process-mark proc))
(insert-before-markers str)
(move-marker comint-last-input-end (point))
+ (setq inferior-haskell-seen-prompt nil)
(comint-send-string proc str)))
(defun inferior-haskell-reload-file ()
@@ -405,8 +420,8 @@ The returned info is cached for reuse by `haskell-doc-mode'."
(let ((sym (match-string 1 type)))
(setq haskell-doc-user-defined-ids
(cons (cons sym (substring type (match-end 0)))
- (remove-if (lambda (item) (equal (car item) sym))
- haskell-doc-user-defined-ids)))))
+ (delq (assoc sym haskell-doc-user-defined-ids)
+ haskell-doc-user-defined-ids)))))
(if (interactive-p) (message "%s" type))
(when insert-value

0 comments on commit ce971bb

Please sign in to comment.