unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15744: 23.3; ansi-term: prompt moves to bottom of screen
@ 2013-10-28 19:02 Olsen, Stuart J
  2013-10-28 19:29 ` Olsen, Stuart J
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Olsen, Stuart J @ 2013-10-28 19:02 UTC (permalink / raw)
  To: 15744

In ansi-term, once the screen has filled with output -- that is, when
the prompt for the shell is at the bottom of the window -- if one scrolls the
buffer so that the prompt is in the middle of the screen, typing
anything into the terminal buffer causes the prompt to snap back down to
the bottom of the window. This is helpful if the prompt is not in view,
but is rather obnoxious if it is, especially when using ZSH, which
displays completions and other information below the prompt, meaning
that that information is hidden once the buffer fills to the size of the
window.

To reproduce the bug, issue `emacs -Q', run the `ansi-term' command,
select an appropriate shell (I have observed this behaviour with both
GNU bash and ZSH), and issue enough commands to the shell to fill the
window. Once the window has been filled, scroll the buffer so the prompt
appears above the bottom of the window. Send any input to the shell, and
the prompt will snap to the bottom of the window.

It may be helpful to note that term.el references at line 1005 a variable
named `term-scroll-to-bottom-on-input', which does not appear to be
referenced anywhere within the code, and which is undefined in my version of
Emacs.


In GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2013-05-16 on panlong, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11103000
configured using `configure  '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.3/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.3/leim' '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Term

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x a n s i - t e r m <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> <return> <return> 
<return> <return> <return> <return> l s <return> <down-mouse-5> 
<mouse-5> <double-down-mouse-5> <double-mouse-5> <triple-down-mouse-5> 
<triple-mouse-5> s <down-mouse-5> <mouse-5> <double-down-mouse-5> 
<double-mouse-5> s <down-mouse-5> <mouse-5> <double-down-mouse-5> 
<double-mouse-5> <triple-down-mouse-5> <triple-mouse-5> 
s s s s <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> M-x s u b <tab> C-g <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<menu-bar> <help-menu> <send-emacs-bug-report>

Recent messages:
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...done
Loading /etc/emacs/site-start.d/50psvn.el (source)...done
Loading /etc/emacs/site-start.d/50slime.el (source)...
Loading /usr/share/emacs23/site-lisp/slime/slime-autoloads.elc...done
Loading /etc/emacs/site-start.d/50slime.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
/usr/share/emacs/23.3/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs23/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/23.3/lisp/textmodes/ispell
/usr/share/emacs23/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/23.3/lisp/textmodes/flyspell

Features:
(shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml
easymenu mml-sec password-cache mm-decode mm-bodies mm-encode mailcap
mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader
gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit
mailheader canlock sha1 hex-util hashcash mail-utils emacsbug term
disp-table ehelp electric ring slime-autoloads emacs-goodies-el
emacs-goodies-custom emacs-goodies-loaddefs easy-mmode tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15744: 23.3; ansi-term: prompt moves to bottom of screen
  2013-10-28 19:02 bug#15744: 23.3; ansi-term: prompt moves to bottom of screen Olsen, Stuart J
@ 2013-10-28 19:29 ` Olsen, Stuart J
  2013-10-29  2:01 ` bug#15744: " Ryan Crum
  2013-10-30 18:08 ` bug#15744: 23.3; " Olsen, Stuart J
  2 siblings, 0 replies; 5+ messages in thread
From: Olsen, Stuart J @ 2013-10-28 19:29 UTC (permalink / raw)
  To: 15744@debbugs.gnu.org

Additionally, sending ^L to the shell, be it bash or ZSH, causes the behaviour
to change slightly; instead of snapping the prompt to the bottom of the window
on input, the terminal snaps the prompt to the top. This behaviour persists
until the screen is again filled with output; at that point, the terminal
reverts to moving the prompt to the bottom of the screen on input.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15744: ansi-term: prompt moves to bottom of screen
  2013-10-28 19:02 bug#15744: 23.3; ansi-term: prompt moves to bottom of screen Olsen, Stuart J
  2013-10-28 19:29 ` Olsen, Stuart J
@ 2013-10-29  2:01 ` Ryan Crum
  2020-08-13 11:02   ` Lars Ingebrigtsen
  2013-10-30 18:08 ` bug#15744: 23.3; " Olsen, Stuart J
  2 siblings, 1 reply; 5+ messages in thread
From: Ryan Crum @ 2013-10-29  2:01 UTC (permalink / raw)
  To: 15744

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)))))







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15744: 23.3; ansi-term: prompt moves to bottom of screen
  2013-10-28 19:02 bug#15744: 23.3; ansi-term: prompt moves to bottom of screen Olsen, Stuart J
  2013-10-28 19:29 ` Olsen, Stuart J
  2013-10-29  2:01 ` bug#15744: " Ryan Crum
@ 2013-10-30 18:08 ` Olsen, Stuart J
  2 siblings, 0 replies; 5+ messages in thread
From: Olsen, Stuart J @ 2013-10-30 18:08 UTC (permalink / raw)
  To: 15744@debbugs.gnu.org, ryan@ryancrum.org

> Here's a patch [...]

Thank you, that works absolutely beautifully.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15744: ansi-term: prompt moves to bottom of screen
  2013-10-29  2:01 ` bug#15744: " Ryan Crum
@ 2020-08-13 11:02   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-13 11:02 UTC (permalink / raw)
  To: Ryan Crum; +Cc: 15744

Ryan Crum <ryan@ryancrum.org> writes:

> 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.

Thanks; the patch still seems to work fine against Emacs 28, so I've
applied it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-13 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-28 19:02 bug#15744: 23.3; ansi-term: prompt moves to bottom of screen Olsen, Stuart J
2013-10-28 19:29 ` Olsen, Stuart J
2013-10-29  2:01 ` bug#15744: " Ryan Crum
2020-08-13 11:02   ` Lars Ingebrigtsen
2013-10-30 18:08 ` bug#15744: 23.3; " Olsen, Stuart J

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).