Inside EXWM (from "term") I opened another Emacs session (
git commit opened it).
How do I close this Emacs session?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
The problem is that any commands you execute such as
C-x C-c will be captured by the Emacs instance running EXWM.
The first thing to try - which did not work for OP - is to execute
M-x exwm-input-grab-keyboard with the secondary Emacs window selected. This will set the window to
char mode, and send the keys you type directly to that window. So
C-x C-c will then cause that secondary Emacs to exit. If this works for you, you can set
exwm-input-toggle-keyboard to a global key (
S-i is a common binding).
If that does not work, you can send keystrokes to the secondary Emacs using
M-x exwm-input-send-next-key. With the secondary Emacs window selected, you run the above command twice, sending first
C-c. This command is bound by default to
C-c C-q - in that case you would type
C-c C-q C-x C-c C-q C-c.
As a last resort, you would open a shell and search for
emacs processes, and kill the secondary Emacs process.
The more important thing is to never let this happen again. You can do that by starting the Emacs daemon from your EXWM startup code with
(server-start) and setting the EDITOR environment variable with
(setenv "EDITOR" "emacsclient"). Then
git commit will open the file in your running Emacs.
The best solution is simply to hit
C-c C-k (
exwm-input-release-keyboard) which puts the X-window containing the inner emacs into char-mode. Then, when that window has focus, almost all keyboard input, including
C-x C-c is passed to the inner emacs.
exwm-reset) to get the window back to normal line-mode.