Subject: Re: bug#27901: 25.1; x-win-suspend-error: Cannot suspend Emacs while running under X

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Aug 2017 22:01:27 +0300

> Date: Sat, 05 Aug 2017 21:43:31 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > (frame-list)
> > (#<frame [email-masked] 0x116995f8> #<frame F1 0xc41680>)
> > 
> > (next-frame)
> > #<frame F1 0xc41680>
> > 
> > (delete-frame (next-frame))
> > ^^
> > shows the bug (I won't do it now because I am working remotely)
> 
> The F1 frame is a TTY frame, so it sounds like you are trying to
> delete the frame through which you are communicating with Emacs?

Yes, that's what happens here.  From the doc string of next-frame:

  (next-frame &optional FRAME MINIFRAME)

  Return the next frame in the frame list after FRAME.
  It considers only frames on the same terminal as FRAME.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So you shouldn't use next-frame for this, but instead find the frame
in the list that is other than the selected frame.