Subject: bug#60966: 30.0.50; Emacs -nw on msys2 is not clearing the terminal

From: Ergus <[email-masked]>
Date: Mon, 23 Jan 2023 22:45:15 +0000 (UTC)

Hi Eli:

Thanks, now I understand the problem... it is a bit weird, but OK.
Today I also tried the nt/INSTALL.64 steps and somehow I got an issue about #include <ms-w32.h>: No such file or directory.
I repeated the steps in the guide carefully but I only get the same error after make.
---------------------------------
In file included from ../src/config.h 3043
../../source/lib/../src/conf_post.h:38:11: fatal error: ms-w32.h: No such file or directory   38 | # include <ms-w32.h>        |compilation terminated
----------------------------------
Any idea? I am using the mingw64 terminal to build as the guide says... so maybe there is anything wrong in my envirnment?
Thanks in advance,Ergus

    On Friday, January 20, 2023 at 08:17:23 PM GMT+1, Eli Zaretskii <[email-masked]> wrote:  
 
 > Date: Fri, 20 Jan 2023 17:40:17 +0100
> From:  Ergus via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> Very recently I have built emacs on MS-Win...10 (please don't ask
>  why). I used msys2 and followed this guide which seems to be very clear
>  and simple:
> 
> https://gist.github.com/nauhygon/f3b44f51b34e89bc54f8
> 
> After the build and installation, everything seemed
> correctly. runemacs.exe works as expected... and in gui it works fine (a
> bit slow to start... but maybe that is not so important now)
> 
> However, when I tried:
> 
> emacs -nw -Q
> 
> I found that emacs was not clearing the terminal on startup.

What is "the terminal" from which you invoke "emacs -nw"?  You should
invoke it from cmd.exe (a.k.a. "Command Prompt") window, not from the
MSYS2 mintty terminal.

> So, emacs is apparently starting correctly (status-line is visible
> and cursos), but the previous text is still on the screen
> overlapping with emacs and making it unusable. If opening a file,
> the file content is inserted bellow the old text, truncating the
> head of the file, but the cursor can move up to the top.
> 
> Moving the cursor down (off the screen) the screen scrolls the file
> content, but the old text stays fix.
> 
> After C-x C-c, emacs exists "correctly" but in this case the terminal is
> actually cleared (Like C-l usually do). Which somehow is not intended,
> because the terminal is expected to be recovered to it's previous
> status right?
> 
> All this was with the current master and the emacs-29 branch.

Emacs isn't that badly broken on Windows, including in -nw sessions.
You should invoke it as a native Windows application, from the Command
Prompt window, not as an MSYS2 application.