Subject: Re: bug#72778: 31.0.50; Calc: g f doesn't display gnuplot window after closing

From: Pip Cet <[email-masked]>
Date: Mon, 26 Aug 2024 19:32:02 +0000

"Michael Heerdegen via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\"" <[email-masked]> writes:
> In Calc, whenever I have displayed a graph view using g f, and then have
> been closing the Gnuplot X window, the next g f or g p will always not
> display the Gnuplot view.  Hitting the keys again displays it, however.

I've investigated this.  This is a gnuplot bug that shows up only under
these conditions:

- qtterm is in use
- the BSD (not GNU) readline library is used (this is true in Debian)
- a window is closed at the wrong time
- a specific call to select() is NOT interrupted by a signal (GDB,
  unfortunately, causes an interrupt at the wrong moment, turning this
  into a Heisenbug)
- gnuplot talks to Emacs using a pty (and, I think, TERM=dumb is also
  required)

I've submitted a patch to gnuplot to fix these issues, but a workaround
is required for, at least, existing gnuplot versions.  Sending an extra
newline character preceding each gnuplot command, as Visuwesh's patch
does, should be both safe and effective, even in the case of several
windows being closed prior to the command that would otherwise be
swallowed.

HTH
Pip