all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: delete-other-frames
Date: Wed, 24 Aug 2016 11:06:49 +0200	[thread overview]
Message-ID: <57BD63A9.8040502@gmx.at> (raw)
In-Reply-To: <83k2f7fugv.fsf@gnu.org>

 > IMO, amend the code.
[...]
 > The latter, I think.

I have two versions to accomplish that: One based on calling
‘next-frame’ exhaustively ...

(defun delete-other-frames (&optional frame)
   "Delete all frames on FRAME's terminal, except FRAME.
If FRAME uses another frame's minibuffer, the minibuffer frame is
left untouched.  FRAME must be a live frame.  FRAME nil or
omitted means use the selected frame."
   (interactive)
   (unless frame
     (setq frame (selected-frame)))
   (let ((minibuffer-frame (window-frame (minibuffer-window frame)))
         (this (next-frame frame t))
         next)
     ;; In a first round consider minibuffer-less frames only.
     (while (not (eq this frame))
       (setq next (next-frame this t))
       (unless (eq (window-frame (minibuffer-window this)) this)
         (delete-frame this))
       (setq this next))
     ;; In a second round consider all remaining frames.
     (setq this (next-frame frame t))
     (while (not (eq this frame))
       (setq next (next-frame this t))
       (unless (eq this minibuffer-frame)
         (delete-frame this))
       (setq this next))))

... and a more conservative one using ‘frame-list’.

(defun delete-other-frames (&optional frame)
   "Delete all frames on FRAME's terminal, except FRAME.
If FRAME uses another frame's minibuffer, the minibuffer frame is
left untouched.  FRAME must be a live frame.  FRAME nil or
omitted means use the selected frame."
   (interactive)
   (unless frame
     (setq frame (selected-frame)))
   (let ((terminal (frame-terminal frame))
	(minibuffer-frame (window-frame (minibuffer-window frame)))
	(frames (frame-list)))
     ;; Clean up candidate frames.
     (dolist (this (prog1 frames (setq frames nil)))
       (when (and (eq (frame-terminal this) terminal)
		 (not (eq this frame))
		 (not (eq this minibuffer-frame)))
	(push this frames)))
     ;; In a first round consider minibuffer-less frames only.
     (dolist (this frames)
       (unless (eq (window-frame (minibuffer-window this)) this)
	(delete-frame this)))
     ;; In a second round consider all remaining frames.
     (dolist (this frames)
       (when (frame-live-p this)
	(delete-frame this)))))

If someone sees weaknesses with either of these approaches, please
tell me.

martin




  parent reply	other threads:[~2016-08-24  9:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23  8:19 delete-other-frames martin rudalics
2016-08-23 14:09 ` delete-other-frames Eli Zaretskii
2016-08-23 17:56   ` delete-other-frames Richard Copley
2016-08-23 18:31     ` delete-other-frames Eli Zaretskii
2016-08-23 19:55       ` delete-other-frames Richard Copley
2016-08-24  9:07     ` delete-other-frames martin rudalics
2016-08-24  9:06   ` martin rudalics [this message]
2016-08-25  9:16     ` delete-other-frames martin rudalics
2016-08-25 14:46       ` delete-other-frames Eli Zaretskii
2016-08-27  1:32         ` delete-other-frames Richard Stallman
2016-08-27  7:40           ` delete-other-frames Eli Zaretskii
     [not found]         ` <<E1bdSUT-00059T-8W@fencepost.gnu.org>
2016-08-27  6:31           ` delete-other-frames Drew Adams
2016-08-27  7:45             ` delete-other-frames Eli Zaretskii
2016-08-27 13:32             ` delete-other-frames allan gottlieb
2016-08-27 13:40               ` delete-other-frames allan gottlieb
2016-08-27 21:45             ` delete-other-frames Richard Stallman
     [not found]           ` <<49a2a9c7-8573-4f07-897f-3eb444679d8a@default>
     [not found]             ` <<E1bdlPn-0005Ch-I4@fencepost.gnu.org>
2016-08-28  0:41               ` delete-other-frames Drew Adams
     [not found] <<57BC072F.9070704@gmx.at>
     [not found] <<<57BC072F.9070704@gmx.at>

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57BD63A9.8040502@gmx.at \
    --to=rudalics@gmx.at \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.