Question

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?

Was it helpful?

Solution 2

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!

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top