Permalink
Browse files

(inferior-haskell-run-command): New var.

Ignore-this: 78471849583849f80f74a9ba2d233afb
(inferior-haskell-run-command): New var.
(inferior-haskell-load-and-run): New command.

(inferior-haskell-map-internal-ghc-ident): New var.
(inferior-haskell-map-internal-ghc-ident): New fun.
(inferior-haskell-find-haddock): Use it.

darcs-hash:20070629193744-c2f2e-d7c8d3485dbfbca599624b4e07920925e5070a26.gz
  • Loading branch information...
1 parent b74e553 commit 3afdf6bcb2656c09596fef21764e07c61ea104a7 monnier committed Jun 29, 2007
Showing with 40 additions and 0 deletions.
  1. +7 −0 ChangeLog
  2. +33 −0 inf-haskell.el
View
@@ -1,5 +1,12 @@
2007-06-29 Stefan Monnier <monnier@iro.umontreal.ca>
+ * inf-haskell.el (inferior-haskell-run-command): New var.
+ (inferior-haskell-load-and-run): New command.
+
+ * inf-haskell.el (inferior-haskell-map-internal-ghc-ident): New var.
+ (inferior-haskell-map-internal-ghc-ident): New fun.
+ (inferior-haskell-find-haddock): Use it.
+
* inf-haskell.el (inferior-haskell-module-alist-file): Use a file in
/tmp rather than ~/ by default.
(inferior-haskell-compute-module-alist):
View
@@ -250,6 +250,19 @@ The process PROC should be associated to a comint buffer."
(ignore-errors ;Don't beep if there were no errors.
(next-error))))))
+(defvar inferior-haskell-run-command ":main")
+
+(defun inferior-haskell-load-and-run (command)
+ "Pass the current buffer's file to haskell and then run a COMMAND."
+ (interactive
+ (list
+ (if (and inferior-haskell-run-command (not current-prefix-arg))
+ inferior-haskell-run-command
+ (read-string "Command to run: " nil nil inferior-haskell-run-command))))
+ (setq inferior-haskell-run-command command)
+ (inferior-haskell-load-file) ;FIXME: Shouldn't that be reload?
+ (inferior-haskell-send-command (inferior-haskell-process) command))
+
(defun inferior-haskell-send-command (proc str)
(setq str (concat str "\n"))
(with-current-buffer (process-buffer proc)
@@ -520,6 +533,25 @@ so that it can be obtained more quickly next time.")
'ok-if-already-exists)))
alist)))))
+(defvar inferior-haskell-ghc-internal-ident-alist
+ ;; FIXME: Fill this table, ideally semi-automatically.
+ '(("GHC.Base.return" . "Control.Monad.return")
+ ("GHC.List" . "Data.List")))
+
+(defun inferior-haskell-map-internal-ghc-ident (ident)
+ "Try to translate some internal GHC identifier to its alter ego in haskell docs."
+ (let ((head ident)
+ (tail "")
+ remapped)
+ (while (and (not
+ (setq remapped
+ (cdr (assoc head
+ inferior-haskell-ghc-internal-ident-alist))))
+ (string-match "\\.[^.]+\\'" head))
+ (setq tail (concat (match-string 0 head) tail))
+ (setq head (substring head 0 (match-beginning 0))))
+ (concat (or remapped head) tail)))
+
;;;###autoload
(defun inferior-haskell-find-haddock (sym)
"Find and open the Haddock documentation of SYM.
@@ -541,6 +573,7 @@ we load it."
(format "Find documentation of (default %s): " sym)
"Find documentation of: ")
nil nil sym))))
+ (setq sym (inferior-haskell-map-internal-ghc-ident sym))
(let* (;; Find the module and look it up in the alist
(module (inferior-haskell-get-module sym))
(alist-record (assoc module (inferior-haskell-module-alist)))

0 comments on commit 3afdf6b

Please sign in to comment.