Skip to content

Commit

Permalink
Scroll more often with nil h-i-m-scroll-to-bottom
Browse files Browse the repository at this point in the history
* Go to the end of a new prompt when the point is on the same line of
that prompt.

* Go to the end of a new result when the point was at the end of the
buffer before inserting that result.
  • Loading branch information
fice-t committed Oct 23, 2016
1 parent 5d67667 commit 4e7533f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
4 changes: 3 additions & 1 deletion haskell-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ If I break, you can:
1. Restart: M-x haskell-process-restart
2. Configure logging: C-h v haskell-process-log (useful for debugging)
3. General config: M-x customize-mode
4. Hide these tips: C-h v haskell-process-show-debug-tips")))))))
4. Hide these tips: C-h v haskell-process-show-debug-tips")))
(with-current-buffer (haskell-interactive-buffer)
(goto-char haskell-interactive-mode-prompt-start))))))

(defun haskell-commands-process ()
"Get the Haskell session, throws an error if not available."
Expand Down
31 changes: 16 additions & 15 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,23 @@ SESSION, otherwise operate on the current buffer."
'front-sticky t)))
(let ((marker (setq-local haskell-interactive-mode-prompt-start (make-marker))))
(set-marker marker (point))))
(when haskell-interactive-mode-scroll-to-bottom
(when (or haskell-interactive-mode-scroll-to-bottom
(haskell-interactive-at-prompt t))
(haskell-interactive-mode-scroll-to-bottom))))

(defun haskell-interactive-mode-eval-result (session text)
"Insert the result of an eval as plain text."
(with-current-buffer (haskell-session-interactive-buffer session)
(save-excursion
(goto-char (point-max))
(let ((prop-text (propertize text
'font-lock-face 'haskell-interactive-face-result
'front-sticky t
'prompt t
'read-only t
'rear-nonsticky t
'result t)))
(let ((at-end (eobp))
(prop-text (propertize text
'font-lock-face 'haskell-interactive-face-result
'front-sticky t
'prompt t
'read-only t
'rear-nonsticky t
'result t)))
(save-excursion
(goto-char (point-max))
(when (string= text haskell-interactive-prompt2)
(put-text-property 0
(length haskell-interactive-prompt2)
Expand All @@ -331,11 +333,10 @@ SESSION, otherwise operate on the current buffer."
(insert (ansi-color-apply prop-text))
(haskell-interactive-mode-handle-h)
(let ((marker (setq-local haskell-interactive-mode-result-end (make-marker))))
(set-marker marker
(point)
(current-buffer)))))
(when haskell-interactive-mode-scroll-to-bottom
(haskell-interactive-mode-scroll-to-bottom))))
(set-marker marker (point))))
(when (or haskell-interactive-mode-scroll-to-bottom
at-end)
(haskell-interactive-mode-scroll-to-bottom)))))

(defun haskell-interactive-mode-scroll-to-bottom ()
"Scroll to bottom."
Expand Down

0 comments on commit 4e7533f

Please sign in to comment.