6

Recently, I'd wanted to commit to my git repository from within emacs. Instead of running some git mode commands, I opened up a terminal buffer and run git commit inside. This works fine, except that the commit message editor is, of course, emacs. Out of habit, I tried to save-close the editor after inserting the commit message, but that closed my parent emacs...

Since I run emacs in client/server mode, I can simply reconnect and have all the buffers still open. But how do I close the child emacs (apart from killing it from within another terminal)?

In general, how do I send ctrl/meta to a program running in the terminal buffer?

Drew
  • 75,699
  • 9
  • 109
  • 225
choeger
  • 191
  • 2
  • Not sure I understand, but are you looking for `C-x #` (`server-edit`) ([see manual](https://www.gnu.org/software/emacs/manual/html_node/emacs/Invoking-emacsclient.html#Invoking-emacsclient))? – Dan Feb 01 '17 at 12:38
  • Since you're already running in server mode, you can set your git to use emacsclient as your commit editor. The arrangement you're using sounds unnecessarily convoluted. – Tyler Feb 01 '17 at 14:17

1 Answers1

6

If you're in term buffer in char mode, you have to escape C-c. So, if you're running a terminal Emacs instance inside the term buffer, running save-buffers-kill-terminal requires an extra C-c: C-x C-c C-c.

If you're running an Emacs instance in a term buffer in line mode, I don't think there's a direct way to kill the nested Emacs. You have to switch back to char mode first, via C-c C-k. Then you can call C-x C-c C-c as above.

That said, rather than starting an Emacs instance from your term buffer, you should call emacsclient instead. That will open up your file in a regular Emacs buffer in the current Emacs instance, without all the confusing nesting of Emacs-inside-term-inside-Emacs.

Tyler
  • 21,719
  • 1
  • 52
  • 92