Reputation: 765
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?
Upvotes: 1
Views: 1298
Reputation: 189317
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!
Upvotes: 1
Reputation: 5198
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.
Upvotes: 4