How do I exit Emacs from the terminal? - emacs

I just installed Emacs 26.3 on Ubuntu 20.04. I opened a buffer in the terminal, and I cannot close it. C-x C-c does nothing. f10 to activate the menu does not activate the menu.
I'm using a .emacs file that maps cut/copy/paste commands to the normal C-x/C-c/C-v. I don't think that this can affect the issue, however, because I have the exact same setup (including the same .emacs file) on by Emacs 24.5/Ubuntu 16.04 laptop, and it has no problem exiting with C-x C-c. Also, I had the exact same problem before I installed the .emacs file on the new system.
How do I kill Emacs?
This question exists, but it has no useful answers.

ESC x save-buffers-kill-terminal
OFC binding C-x will affect C-x C-c. You don't need to know anything about Emacs to realize the problem. Just think twice.

Related

Emacs Mode Line Click Change Buffer

In some installation of Emacs for the terminal, I had that if you click (text mouse cursor) on the buffer name in the mode line it jumped to the next buffer.
I search for a while but I couldn't find it.
Do someone remembers how to achieve this.
OS : OS X Terminal
Emacs: GNU Emacs 26.3
(Now I have Catalina, but I should have been in previous versions)
Try turning on mouse mode in your terminal emacs: M-x xterm-mouse-mode RET. This seems to work with emacs -nw in either an xterm or a gnome-terminal on linux. Whether it works on OS X and whatever terminal emulator it provides, I have no idea.
This Unix & Linux SE question contains much more information and some useful links.

How to configure simpleclip in emacs terminal mode to copy-paste interchangeably with OS?

I'm using emacs -nw (Emacs 24.5, Ubuntu 16.04). And I found that the default emacs M-w C-y keys don't work interchangeably with the operating system.
After some research, it seems that the most comprehensive solution is to use simpleclip. EmacsWiki says that
simpleclip
You can use https://github.com/rolandwalker/simpleclip which ALWAYS
works.
But looking into its usage guide above, simpleclip makes use of a set of keys that are completely different from the default M-w C-y or the OS Ctrl-Shift-c, Ctrl-Shift-v for copy-paste
;; Press super-c to copy without affecting the kill ring.
;; Press super-x or super-v to cut or paste.
I don't really want to use super key a lot with my PC keyboards, and don't want to remember (or persuade others to remember) yet another set of copy-paste keys.
For the GUI emacs, I can copy something in emacs and paste it into another terminal without any configuration. Mostly, I don't feel that Emacs is any different from gedit except that the emacs copy-paste keys M-w C-y can be used in addition.
In the terminal mode, most of it breaks down. If I use OS copy (Ctrl-Shift-c), one line in emacs can be copied into two or more lines in a target terminal because the line is too long. contents copied using M-w simply do not paste into other programs, even though I tried to set certain variables following other SO questions, e.g.:
(setq x-select-enable-clipboard t)
I'm not very familiar with elisp. My question:
How can I customize or configure simpleclip so that copy-paste in emacs -nw is exactly the same as copy-paste in the OS?
Other related SO questions:
How to copy text from Emacs to another application on Linux
emacs terminal mode: how to copy and paste efficiently
I recommend you use the xclip package, which you can install from GNU ELPA (i.e. via M-x package-list-packages). It requires installation of the xclip utility under X11 (e.g. via aptitude install xclip) and uses the pbcopy/pbpaste under macOS.

close emacs from remote computer

I forgot to close emacs at work which has buffers which are not saved.
Is there a way to close emacs from my remote computer using an ssh connection with forcing emacs to save all buffers?
You can kill the Emacs process from a shell. Emacs will have produced auto-save information for all file-related buffers.
Then start a new emacs, type M-x recover-session, and you will see a list of recent sessions to recover.
Type C-c C-c on the latest and follow instructions.

Run latex within Emacs

I used to launch latex within Emacs on a .tex file by C-c C-c.
I just changed my machine, and need to reconfigure all. I have already installed texlive-full, and copied .emacs from the previous machine to the new machine.
When I open a .tex file under Emacs, launch C-c C-c, and then type LaTeX, it opens another buffer, named *tex-shell*, and looks like as so:
Could anyone tell me what happened?
I don't really now what happen, but it seem you want to use auctex:
sudo apt-get install auctex
and relaunch Emacs should solve your problem.

In emacs, query-replace-regexp keyboard shortcut doesn't work in the terminal (e.g., emacs -nw)

Is it expected that C-M-% and ESC C-% do not run the command query-replace-regexp when running emacs in a terminal window (for example, emacs -nw)?
According to describe-function the binding exists, but emacs runs query-replace instead (which has the binding M-%). This has happened on several machines I've tried it on, and does not happen when I run emacs in a window.
The problem is that C-% simply can't be typed in a terminal. The only control sequences available are those that corresponds to ascii-code 0-31, mainly C-letter.
I have created a new shortcut in my .emacs file.
(global-set-key "\M-q" 'query-replace-regexp)
Control-Alt-Shift-% all together works on Windows and Fedora Linux. Does your keyboard have all those keys?