~ubuntu-branches/ubuntu/trusty/haskell-mode/trusty-proposed

« back to all changes in this revision

Viewing changes to inf-haskell.el

  • Committer: Package Import Robot
  • Author(s): Barak A. Pearlmutter
  • Date: 2013-12-27 17:38:40 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20131227173840-5qjuscd4uj7ag382
Tags: 13.10-2
* build dependency on texinfo for /usr/bin/makeinfo (closes: #730955)
* no haskell-ghci.el breaking agda-mode (<< 2.3.2) (closes: #731326)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;;; inf-haskell.el --- Interaction with an inferior Haskell process.
 
1
;;; inf-haskell.el --- Interaction with an inferior Haskell process
2
2
 
3
3
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
4
4
 
31
31
;;; Code:
32
32
 
33
33
(require 'comint)
34
 
(require 'shell)                        ;For directory tracking.
 
34
(require 'shell)             ; For directory tracking.
35
35
(require 'compile)
36
36
(require 'haskell-mode)
37
37
(require 'haskell-decl-scan)
98
98
          ;; Foo.hs:318:80:
99
99
          ;;     Ambiguous occurrence `Bar'
100
100
          ;;     It could refer to either `Bar', defined at Zork.hs:311:5
101
 
          ;;                      or `Bar', imported from Bars at Frob.hs:32:0-16
102
 
          ;;                                   (defined at Location.hs:97:5)
 
101
          ;;                  or `Bar', imported from Bars at Frob.hs:32:0-16
 
102
          ;;                       (defined at Location.hs:97:5)
103
103
          ("[ (]defined at \\(.+\\):\\([0-9]+\\):\\([0-9]+\\))?$" 1 2 3 0)
104
104
          ("imported from .* at \\(.+\\):\\([0-9]+\\):\\([0-9]+\\)-\\([0-9]+\\)$"
105
105
           1 2 (3 . 4) 0)
119
119
  :group 'inferior-haskell
120
120
  (set (make-local-variable 'comint-prompt-regexp)
121
121
       ;; Whay the backslash in [\\._[:alnum:]]?
122
 
       "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?: \\*?[[:upper:]][\\._[:alnum:]]*\\)*> \\|^> $")
 
122
       "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?: \\*?[[:upper:]][\\._[:alnum:]]*\\)*> \\|^λ?> $")
123
123
  (set (make-local-variable 'comint-input-autoexpand) nil)
124
124
  (add-hook 'comint-preoutput-filter-functions
125
125
            'inferior-haskell-send-decl-post-filter)
157
157
(defun inferior-haskell-string-to-strings (string)
158
158
  "Split the STRING into a list of strings."
159
159
  (let ((i (string-match "[\"]" string)))
160
 
    (if (null i) (split-string string)  ; no quoting:  easy
 
160
    (if (null i) (split-string string) ; no quoting:  easy
161
161
      (append (unless (eq i 0) (split-string (substring string 0 i)))
162
 
              (let ((rfs (read-from-string string i)))
163
 
                (cons (car rfs)
164
 
                      (inferior-haskell-string-to-strings
165
 
                       (substring string (cdr rfs)))))))))
 
162
              (let ((rfs (read-from-string string i)))
 
163
                (cons (car rfs)
 
164
                      (inferior-haskell-string-to-strings
 
165
                       (substring string (cdr rfs)))))))))
166
166
 
167
167
(defun inferior-haskell-command (arg)
168
168
  (inferior-haskell-string-to-strings
180
180
setting up the inferior-haskell buffer."
181
181
  (interactive (list (inferior-haskell-command current-prefix-arg)))
182
182
  (setq inferior-haskell-buffer
183
 
        (apply 'make-comint "haskell" (car command) nil (cdr command)))
 
183
        (apply 'make-comint "haskell" (car command) nil (cdr command)))
184
184
  (with-current-buffer inferior-haskell-buffer
185
185
    (inferior-haskell-mode)
186
186
    (run-hooks 'inferior-haskell-hook)))
187
187
 
188
188
(defun inferior-haskell-process (&optional arg)
189
189
  (or (if (buffer-live-p inferior-haskell-buffer)
190
 
          (get-buffer-process inferior-haskell-buffer))
 
190
          (get-buffer-process inferior-haskell-buffer))
191
191
      (progn
192
 
        (let ((current-prefix-arg arg))
193
 
          (call-interactively 'inferior-haskell-start-process))
194
 
        ;; Try again.
195
 
        (inferior-haskell-process arg))))
 
192
        (let ((current-prefix-arg arg))
 
193
          (call-interactively 'inferior-haskell-start-process))
 
194
        ;; Try again.
 
195
        (inferior-haskell-process arg))))
196
196
 
197
197
;;;###autoload
198
198
(defalias 'run-haskell 'switch-to-haskell)
216
216
             #1=(string-match inferior-haskell-multiline-prompt-re string))
217
217
    ;; deleting sequence of `%s|' multiline promts
218
218
    (while #1#
219
 
      (setq string (substring string (match-end 0))))    
 
219
      (setq string (substring string (match-end 0))))
220
220
    ;; deleting regular prompts
221
221
    (setq string (replace-regexp-in-string comint-prompt-regexp "" string)
222
222
          ;; turning off this post-filter
223
 
          inferior-haskell-send-decl-post-filter-on nil))  
 
223
          inferior-haskell-send-decl-post-filter-on nil))
224
224
  string)
225
225
 
226
226
(defvar inferior-haskell-seen-prompt nil)
323
323
  (save-buffer)
324
324
  (let ((buf (current-buffer))
325
325
        (file buffer-file-name)
326
 
        (proc (inferior-haskell-process)))
 
326
        (proc (inferior-haskell-process)))
327
327
    (if file
328
328
        (with-current-buffer (process-buffer proc)
329
329
          (compilation-forget-errors)