[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#15744: ansi-term: prompt moves to bottom of screen
From: |
Ryan Crum |
Subject: |
bug#15744: ansi-term: prompt moves to bottom of screen |
Date: |
Mon, 28 Oct 2013 22:01:25 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
Here's a patch that adds a variable `term-scroll-snap-to-bottom` in an attempt
resolve this. It defaults to t to preserve current behavior (arguably best for
curses-type interactions), but when you set it to nil it keeps your current
scrolling position while typing as long as the prompt is still visible in the
window.
It also works with `term-scroll-show-maximum-output` to handle cases where
output is printed below the prompt (ala zsh).
This patch is against trunk.
-Ryan
*** term.el.orig Mon Oct 28 21:53:50 2013
--- term.el Mon Oct 28 21:53:05 2013
*************** This variable is buffer-local."
*** 551,556 ****
--- 551,564 ----
:type 'boolean
:group 'term)
+ (defcustom term-scroll-snap-to-bottom t
+ "If t, when the prompt is visible within the buffer then scroll
+ so that the prompt is on the bottom on any input or output.
+
+ The default is t."
+ :type 'boolean
+ :group 'term)
+
(defcustom term-scroll-show-maximum-output nil
"Controls how interpreter output causes window to scroll.
If non-nil, then show the maximum output when the window is scrolled.
*************** See `term-prompt-regexp'."
*** 3114,3128 ****
(or (eq scroll 'this) (not save-point)))
(and (eq scroll 'others)
(not (eq selected win))))
! (goto-char term-home-marker)
! (recenter 0)
(goto-char (process-mark proc))
(if (not (pos-visible-in-window-p (point) win))
(recenter -1)))
;; Optionally scroll so that the text
;; ends at the bottom of the window.
(when (and term-scroll-show-maximum-output
! (>= (point) (process-mark proc)))
(save-excursion
(goto-char (point-max))
(recenter -1)))))
--- 3122,3139 ----
(or (eq scroll 'this) (not save-point)))
(and (eq scroll 'others)
(not (eq selected win))))
! (when term-scroll-snap-to-bottom
! (goto-char term-home-marker)
! (recenter 0))
(goto-char (process-mark proc))
(if (not (pos-visible-in-window-p (point) win))
(recenter -1)))
;; Optionally scroll so that the text
;; ends at the bottom of the window.
(when (and term-scroll-show-maximum-output
! (>= (point) (process-mark proc))
! (or term-scroll-snap-to-bottom
! (not (pos-visible-in-window-p (point-max)
win))))
(save-excursion
(goto-char (point-max))
(recenter -1)))))