0

In OSX, pressing C-x C-c closes all Emacs windows instead of only the selected one. This isn't the bahavior I've come to esxpect from using Emacs on Windows, Ubuntu,or CentOS. What's up?

  • C-x C-c exits Emacs, i.e. it closes all open frames. It works the same on all operating systems. If you just want to close the current frame, use C-x 5 0. – Lindydancer Jun 4 '19 at 8:21
  • @Lindydancer On other systems opening a new file from outside creates a new instance. – Aido Jun 4 '19 at 14:54
6

C-x C-c is for Kill Emacs (save-buffers-kill-terminal).

Maybe on other systems you are using emacsclient, then

C-x C-c behaves specially if you are using Emacs as a server. If you type it from a client frame, it closes the client connection.

Or maybe you run multiple instances of Emacs?

To close only one frame use C-x 5 0 or s-w.

This command delete current frame or kill Emacs if there are only one frame:

(defun close-frame-or-kill-emacs ()
  "Delete frame or kill Emacs if there are only one frame."
  (interactive)
  (if (> (length (frame-list)) 1)
      (delete-frame)
    (save-buffers-kill-terminal)))
| improve this answer | |
  • Darn, that's really annoying. C-x 5 0 and s-w won't close the last frame either. On other systems I just use the default emacs or emacs.exe, however it comes. – Aido Jun 3 '19 at 20:43
  • 2
    @Aido, in the absence of the client/server feature, C-x C-c has always been for quitting the Emacs instance -- which means closing all of its frames. If you are not using emacsclient then the only explanation which makes any sense is that, rather than using multiple frames of a single Emacs instance, you are running multiple instances of Emacs (in which case C-x C-c would close only the one you were using at that time). – phils Jun 4 '19 at 0:01
  • @phils Yeah, it looks like that. I've got a script from my dad that randomizes the background color of each instance, and on OSX they're all the same until you close and reopen every window. – Aido Jun 4 '19 at 5:20
  • 1
    @Aido Added close-frame-or-kill-emacs command to answer. Bind it to s-w so it will "close" the last frame. – muffinmad Jun 4 '19 at 8:19
  • @muffinmad Good idea, thank you! – Aido Jun 4 '19 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.