How can I close all opened frames in emacsclient?

1.1k views Asked by At

I have a lot of frames always open in emacs. Like I use emacsclient (daemon) and almost never restart my computer, these frames are never close. I could close one with C-x k but how to close all opened frames?

2

There are 2 answers

1
tripleee On BEST ANSWER

This seems to work acceptably. It will ask you if one of the buffers on the kill list has unsaved changes.

(defun close-all-other-buffers-and-frames ()
  "Destroy all frames except this one, kill all buffers, display `*scratch*'."
  (interactive)
  (set-buffer "*scratch*")
  (delete-other-frames)
  (let ((l (buffer-list)) b)
    (while l
      (setq b (car l)
            l (cdr l) )
      (and (buffer-file-name b)
           (kill-buffer b) ) ) ) )

I have a feeling the loop to kill buffers could be done more elegantly -- please suggest improvements!

7
Tobias On

Closing all frames is just quitting, is it not?

If you want to close all but one frame you can use delete-other-frames with the key-sequence C-x 5 1.