Skip to content

Commit a69332a

Browse files
committed
Merge pull request #696 from geraldus/haskell-presentaions-fix
Haskell presentaions fix
2 parents 6c56c3f + d4892b2 commit a69332a

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

haskell-commands.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ If variable `haskell-process-use-presentation-mode' is NIL it will output
966966
modified message MSG to echo area."
967967
(if haskell-process-use-presentation-mode
968968
(let ((session (haskell-process-session (haskell-interactive-process))))
969-
(haskell-present session msg))
969+
(haskell-presentation-present session msg))
970970
(let ((m (haskell-utils-reduce-string msg)))
971971
(message m))))
972972

haskell-interactive-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,8 @@ don't care when the thing completes as long as it's soonish."
10961096
(defun haskell-process-show-repl-response (line)
10971097
"Send LINE to the GHCi process and echo the result in some fashion.
10981098
Result will be printed in the minibuffer or presented using
1099-
haskell-present, depending on variable `haskell-process-use-presentation-mode'."
1099+
function `haskell-presentation-present', depending on variable
1100+
`haskell-process-use-presentation-mode'."
11001101
(let ((process (haskell-interactive-process)))
11011102
(haskell-process-queue-command
11021103
process
@@ -1106,7 +1107,7 @@ haskell-present, depending on variable `haskell-process-use-presentation-mode'."
11061107
(haskell-process-send-string (car state) (cdr state)))
11071108
:complete (lambda (state response)
11081109
(if haskell-process-use-presentation-mode
1109-
(haskell-present
1110+
(haskell-presentation-present
11101111
(haskell-process-session (car state))
11111112
response)
11121113
(haskell-mode-message-line response)))))))

haskell-presentation-mode.el

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,59 @@
3434
\\{hypertext-mode-map}"
3535
(setq case-fold-search nil))
3636

37-
(defconst haskell-present-buffer-name
37+
(defconst haskell-presentation-buffer-name
3838
"*Haskell Presentation*"
3939
"Haskell Presentation buffer name.")
4040

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

4545
(easy-mmode-defmap
4646
haskell-presentation-mode-map
47-
`(("q" . #'quit-window)
48-
("c" . #'haskell-present-clear))
47+
`(("q" . quit-window)
48+
("c" . haskell-presentation-clear))
4949
"The base key map for `haskell-presentation-mode'.")
5050

51-
(defun haskell-present-clear ()
51+
(defun haskell-presentation-buffer ()
52+
"Return Haskell Presentaion buffer.
53+
Return current presenation buffer or create new one if absent.
54+
Never returns nil."
55+
;; TODO Provide interactive calling options: when called interactively make
56+
;; the presentation buffer current.
57+
(let ((may-buffer (get-buffer haskell-presentation-buffer-name)))
58+
(if may-buffer
59+
may-buffer
60+
(let ((buffer (generate-new-buffer haskell-presentation-buffer-name)))
61+
(with-current-buffer buffer
62+
(insert haskell-presentation-hint-message)
63+
(haskell-presentation-mode)
64+
(setq buffer-read-only t))
65+
buffer))))
66+
67+
(defun haskell-presentation-clear ()
5268
"Clear Haskell Presentation buffer."
5369
(interactive)
54-
(let ((hp-buf (get-buffer haskell-present-buffer-name)))
70+
(let ((hp-buf (get-buffer haskell-presentation-buffer-name)))
5571
(when hp-buf
5672
(with-current-buffer hp-buf
5773
(let ((buffer-read-only nil))
5874
(erase-buffer)
59-
(insert haskell-present-hint-message))))))
75+
(insert haskell-presentation-hint-message))))))
6076

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

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

74-
(when clear (haskell-present-clear))
89+
(when clear (haskell-presentation-clear))
7590
(haskell-session-assign session)
7691
(save-excursion
7792
(let ((buffer-read-only nil))

0 commit comments

Comments
 (0)