Skip to content

Commit

Permalink
Support multiple presentations at once in the same REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Jun 27, 2014
1 parent d027f9f commit 47d90c8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -888,22 +888,25 @@ FILE-NAME only."
p (concat "let it = Present.asData (" expr ")"))))
(if (not (string= "" error))
(haskell-interactive-mode-eval-result (haskell-session) (concat error "\n"))
(let* ((hash (haskell-interactive-mode-presentation-hash))
(presentation (haskell-interactive-mode-present-id
hash
(list 0))))
(insert "\n")
(haskell-interactive-mode-insert-presentation hash presentation)
(haskell-interactive-mode-eval-result (haskell-session) "\n")))
(let ((hash (haskell-interactive-mode-presentation-hash)))
(haskell-process-queue-sync-request
p (format "let %s = Present.asData (%s)" hash expr))
(let* ((presentation (haskell-interactive-mode-present-id
hash
(list 0))))
(insert "\n")
(haskell-interactive-mode-insert-presentation hash presentation)
(haskell-interactive-mode-eval-result (haskell-session) "\n"))))
(haskell-interactive-mode-prompt (haskell-session)))))

(defvar haskell-interactive-mode-presentation-hash 0
"Counter for the hash.")

(defun haskell-interactive-mode-presentation-hash ()
"Generate a presentation hash."
(setq haskell-interactive-mode-presentation-hash
(1+ haskell-interactive-mode-presentation-hash)))
(format "_present_%s"
(setq haskell-interactive-mode-presentation-hash
(1+ haskell-interactive-mode-presentation-hash))))

(define-button-type 'haskell-presentation-slot-button
'action 'haskell-presentation-present-slot
Expand Down Expand Up @@ -1040,8 +1043,9 @@ they're both up to date, or report a bug."))
p "let _it = it")
(let* ((text (haskell-process-queue-sync-request
p
(format "Present.putStr (Present.encode (Present.fromJust (Present.present (Present.fromJust (Present.fromList [%s])) it)))"
(mapconcat 'identity (mapcar 'number-to-string id) ","))))
(format "Present.putStr (Present.encode (Present.fromJust (Present.present (Present.fromJust (Present.fromList [%s])) %s)))"
(mapconcat 'identity (mapcar 'number-to-string id) ",")
hash)))
(reply
(if (string-match "^*** " text)
'((rep nil))
Expand Down

0 comments on commit 47d90c8

Please sign in to comment.