Want real shell mode in Emacs? Using M-x shell only gives terminal emulation, which sometimes doesn’t display things correctly and which, since it supports all Emacs key bindings, makes you do things like use M-p instead of C-p to bring up previous commands in the command buffer ring. Most of the time Shell mode is fine and actually preferable, but if you need a true terminal/shell mode, use M-x term. In this mode it at first appears none of the usual Emacs key-bindings work — How do you change windows?? The secret is to use C-c instead of C-x as your command prefix, e.g. use C-c o instead of C-x o to change windows. To use the M-x commands or any other command, just precede the command with C-c. Thus use C-c M-x compile instead of just M-x compile. Try it. You’ll like it. (Hey I know this is too simple for Emacs gurus with megabyte long .emacs configuration files, but not all of us know these tricks, not even some long time users).