Skip to content

Haskell presentaions fix #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion haskell-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ If variable `haskell-process-use-presentation-mode' is NIL it will output
modified message MSG to echo area."
(if haskell-process-use-presentation-mode
(let ((session (haskell-process-session (haskell-interactive-process))))
(haskell-present session msg))
(haskell-presentation-present session msg))
(let ((m (haskell-utils-reduce-string msg)))
(message m))))

Expand Down
5 changes: 3 additions & 2 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,8 @@ don't care when the thing completes as long as it's soonish."
(defun haskell-process-show-repl-response (line)
"Send LINE to the GHCi process and echo the result in some fashion.
Result will be printed in the minibuffer or presented using
haskell-present, depending on variable `haskell-process-use-presentation-mode'."
function `haskell-presentation-present', depending on variable
`haskell-process-use-presentation-mode'."
(let ((process (haskell-interactive-process)))
(haskell-process-queue-command
process
Expand All @@ -1106,7 +1107,7 @@ haskell-present, depending on variable `haskell-process-use-presentation-mode'."
(haskell-process-send-string (car state) (cdr state)))
:complete (lambda (state response)
(if haskell-process-use-presentation-mode
(haskell-present
(haskell-presentation-present
(haskell-process-session (car state))
response)
(haskell-mode-message-line response)))))))
Expand Down
37 changes: 26 additions & 11 deletions haskell-presentation-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,59 @@
\\{hypertext-mode-map}"
(setq case-fold-search nil))

(defconst haskell-present-buffer-name
(defconst haskell-presentation-buffer-name
"*Haskell Presentation*"
"Haskell Presentation buffer name.")

(defconst haskell-present-hint-message
(defconst haskell-presentation-hint-message
"-- Hit `q' to close this window; `c' to clear.\n\n"
"Hint message appered in Haskell Presentation buffer.")

(easy-mmode-defmap
haskell-presentation-mode-map
`(("q" . #'quit-window)
("c" . #'haskell-present-clear))
`(("q" . quit-window)
("c" . haskell-presentation-clear))
"The base key map for `haskell-presentation-mode'.")

(defun haskell-present-clear ()
(defun haskell-presentation-buffer ()
"Return Haskell Presentaion buffer.
Return current presenation buffer or create new one if absent.
Never returns nil."
;; TODO Provide interactive calling options: when called interactively make
;; the presentation buffer current.
(let ((may-buffer (get-buffer haskell-presentation-buffer-name)))
(if may-buffer
may-buffer
(let ((buffer (generate-new-buffer haskell-presentation-buffer-name)))
(with-current-buffer buffer
(insert haskell-presentation-hint-message)
(haskell-presentation-mode)
(setq buffer-read-only t))
buffer))))

(defun haskell-presentation-clear ()
"Clear Haskell Presentation buffer."
(interactive)
(let ((hp-buf (get-buffer haskell-present-buffer-name)))
(let ((hp-buf (get-buffer haskell-presentation-buffer-name)))
(when hp-buf
(with-current-buffer hp-buf
(let ((buffer-read-only nil))
(erase-buffer)
(insert haskell-present-hint-message))))))
(insert haskell-presentation-hint-message))))))

(defun haskell-present (session code &optional clear)
(defun haskell-presentation-present (session code &optional clear)
"Present given code in a popup buffer.
Creates temporal Haskell Presentation buffer and assigns it to
given haskell SESSION; presented CODE will be fontified as
haskell code. Give an optional non-nil CLEAR arg to clear the
buffer before presenting message."
(let ((buffer (get-buffer-create haskell-present-buffer-name)))
(let ((buffer (haskell-presentation-buffer)))
(with-current-buffer buffer
(haskell-presentation-mode)

(when (boundp 'shm-display-quarantine)
(set (make-local-variable 'shm-display-quarantine) nil))

(when clear (haskell-present-clear))
(when clear (haskell-presentation-clear))
(haskell-session-assign session)
(save-excursion
(let ((buffer-read-only nil))
Expand Down