Subject: bug#50237: 28.0.50; [calc] Default terminal when plotting in gnuplot without x11 support

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 31 Aug 2021 03:48:26 +0200

Ihor Radchenko <[email-masked]> writes:

> Sorry, I was not clear enough. My Emacs is compiled with X11 support,
> but my Gnuplot does not have X11 support. To reproduce, you need to
> compile Gnuplot without X11 support.

Oh, I see.

Looking at the `calc-graph-plot', it guesses at the display type to use
by looking at what abilities the Emacs has:

		    ((calc-graph-w32-p)
		     "qt")
		    ((or (eq window-system 'x) (getenv "DISPLAY"))

So it's doing a "set terminal x11", which then gnuplot rejects.

For this to work correctly, I think calc would have to ask gnuplot:

> The following is output of "set term" command in gnuplot. x11 terminal
> is not there.
>
> Available terminal types:
>        cairolatex  LaTeX picture environment using graphicx package and Cairo backend
>            canvas  HTML Canvas object
>               cgm  Computer Graphics Metafile
>           context  ConTeXt with MetaFun (for PDF documents)
>           domterm  DomTerm terminal emulator with embedded SVG

And then parse the output to see whether gnuplot supports our guess?
Or see what gnuplot said when we tried to change the terminal...  Hm...

Let's see...

(calc-gnuplot-command "set terminal" "lala")

gnuplot> 
Terminal type is now 'unknown'
                      ^
         unknown or ambiguous terminal type; type just 'set terminal' for a list

Yup, that got the expected error...

OK; I've now pushed a fix for this to Emacs 28 which seems to work in my
simulated test case.  Can you update Emacs and see whether it works for
you, too?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no