Subject: Re: bug#77233: 31.0.50; crash if message starts with a space and then without it

From: Daniel Clemente <[email-masked]>
Date: Wed, 26 Mar 2025 14:24:04 +0000

> > If it's urgent, maybe try to comment out the emacs_abort in cmcheckmagic
> > and see if that suffices.
>
> That avoids the crash here, and things work fine in an xterm, but it
> means we printed a character with the cursor at (cols-1,rows-1), which
> allegedly would have caused some (old, I assume?) terminals to scroll by
> a line, destroying the entire Emacs layout...
>
> However, xterm and M-x term both handle this situation sensibly, not
> scrolling the frame.  Is anyone aware of a terminal emulator that
> scrolls in this situation?

If I comment the emacs_abort, I see everything scroll 1 line upwards,
in many terminals: xterm, urxvt, mlterm, Eterm, lxterm,
cool-retro-term.
Every C-x C-e scrolls it 1 line. C-l fixes it.
I have several customizations in .Xresources that may affect what I'm
seeing in some terminal, but not in all the ones I tested.  I don't
know why doesn't your Emacs-in-xterm scroll. Did you run the part that
sets the background color?

On first thought it seems safer to avoid printing at (cols-1, rows-1)
when we know that AutoWrap is enabled…

I know this is a different language and scenario, but I just checked
ncurses in Python, and it rejects writing at the bottom right corner:
  File "/n/cursor1.py", line 41, in main
    stdscr.addstr(y, x, letter, curses.color_pair(1))
_curses.error: addwstr() returned ERR

However, with C and using terminal sequences, I saw it's possible to
print at the bottom right without scrolling, in all of the terminal
emulators mentioned above.
I attach a test program that prints a letter in all four corners and
in the center, and doesn't scroll.
I don't know why Emacs scrolls but this test program doesn't (even
with autoscroll on). I don't know enough about terminals, so please
forgive my small mistakes.