Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FAQ: gnuplot vs. emacs' compile command

7 views
Skip to first unread message

Dan Jacobson

unread,
May 10, 2003, 1:31:43 AM5/10/03
to
What's the big problem that
$ cat Makefile
gp:
echo "plot 'file';pause -1"|gnuplot -persist
$ make #works fine
$ emacs -eval '(compile "make")' #doesn't plot anything.
$ emacs -eval '(shell-command "make")' #works wonderfully
$ emacs -eval '(shell-command "make&")' #doesn't plot anything

Sure you'll tell me to see /usr/share/doc/gnuplot-doc/0FAQ.gz's
"7.10 Calling gnuplot in a pipe or with a gnuplot-script doesn't produce a plot!"
but even that fancy perl example doesn't cover my emacs vs. gnuplot
dilemma.

Or you will try to change the subject by offering
http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/
But that doesn't answer my question of how does one run gnuplot from a
Makefile in GNU emacs' compile mode?

Don't tell me that there is no way for this to be overcome.
I will never be able to do it "because the technology Jacobson was
asking for was 5-10 years in the future." "He was essentially asking
for plugging the standard input to the standard putoff, no simple
algorithm there."

OK, one can indeed do
gp:
echo -e 1\\n2 > a
echo "plot 'a';pause $p" > b
gnuplot b
With p=-1, the compilation never finished even after the window closes.
With p=5 etc, one has to set an arbitrary time limit, however the
compilation will indeed finish.
-persist doesn't help here.
--
http://jidanni.org/ Taiwan(04)25854780

Hans-Bernhard Broeker

unread,
May 10, 2003, 4:41:23 PM5/10/03
to
Dan Jacobson <jid...@dman.ddts.net> wrote:
> What's the big problem that
> $ cat Makefile
> gp:
> echo "plot 'file';pause -1"|gnuplot -persist
> $ make #works fine
> $ emacs -eval '(compile "make")' #doesn't plot anything.
> $ emacs -eval '(shell-command "make")' #works wonderfully
> $ emacs -eval '(shell-command "make&")' #doesn't plot anything

Quite hard to tell, actually. You've piled up three big programs
together (four, if you count in the shell), and somehow the combination
of all of them fails to do quite exactly what you want.

From the symptoms you quote, I'd put the blame at emacs, or the way
you're using it. You're also over-doing things on the gnuplot end a
bit. You should use either "pause -1", or "-persist". Doing both is
not generally useful.

"Doesn't plot anything" is not the whole story, either. What *else*
do you see? I.e.: what _does_ it do? What is displayed in your
*compile* buffer in emacs? Did you actually type a <Return> into the
compilation buffer to satisfy your "pause -1"?


--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Dan Jacobson

unread,
May 11, 2003, 12:42:29 AM5/11/03
to
cd /tmp && echo -e 1 1\\n2 2 >file && cat >Makefile<<!

gp:
echo "plot 'file';pause -1"|gnuplot -persist
!

emacs -eval '(compile "make")' #doesn't plot anything.
emacs -eval '(shell-command "make&")' #doesn't plot anything
emacs -eval '(shell-command "make")' #works wonderfully
make #works fine

H> Quite hard to tell, actually. You've piled up three big programs
H> together (four, if you count in the shell), and somehow the combination
H> of all of them fails to do quite exactly what you want.
H>
H> From the symptoms you quote, I'd put the blame at emacs, or the way
H> you're using it. You're also over-doing things on the gnuplot end a
H> bit. You should use either "pause -1", or "-persist". Doing both is
H> not generally useful.
H>
H> "Doesn't plot anything" is not the whole story, either. What *else*
H> do you see? I.e.: what _does_ it do? What is displayed in your
H> *compile* buffer in emacs? Did you actually type a <Return> into the
H> compilation buffer to satisfy your "pause -1"?
No, it's all over before I have a chance.
Using emacs -eval '(compile "make")'
With: echo "plot 'file';pause -1"|gnuplot -persist
just flashes the graph for a split second.
With:
echo "plot 'file'" |gnuplot
echo "plot 'file'" |gnuplot -persist


echo "plot 'file';pause -1"|gnuplot

apparently gnuplot acts like a noop, no graph is seen; gnuplot's exit
value is 0.

Ethan Merritt

unread,
May 11, 2003, 3:10:55 PM5/11/03
to
In article <87d6iqh...@jidanni.org>,

Dan Jacobson <jid...@dman.ddts.net> wrote:
>cd /tmp && echo -e 1 1\\n2 2 >file && cat >Makefile<<!
>gp:
> echo "plot 'file';pause -1"|gnuplot -persist
>!
>emacs -eval '(compile "make")' #doesn't plot anything.
>emacs -eval '(shell-command "make&")' #doesn't plot anything
>emacs -eval '(shell-command "make")' #works wonderfully
>make #works fine
>
>H> do you see? I.e.: what _does_ it do? What is displayed in your
>H> *compile* buffer in emacs? Did you actually type a <Return> into the
>H> compilation buffer to satisfy your "pause -1"?
>No, it's all over before I have a chance.
>Using emacs -eval '(compile "make")'
>With: echo "plot 'file';pause -1"|gnuplot -persist
>just flashes the graph for a split second.
>With:
1 > echo "plot 'file'" |gnuplot
2 > echo "plot 'file'" |gnuplot -persist
3 > echo "plot 'file';pause -1"|gnuplot

>apparently gnuplot acts like a noop, no graph is seen; gnuplot's exit
>value is 0.

This seems to indicate a misunderstanding of emac's handling of
shell creation rather than anything specific to gnuplot.
Perhaps you would do better to ask in an emacs forum?

It may even be a machine-specific configuration issue. On my machine
(tcsh + emacs-21.2-12mdk) your 2nd variant above (| gnuplot -persist)
works fine; the other two do not. That makes plenty of sense to me,
since option 1 would not persist even if executed from the command line,
while option 3 depends on the handling of STDIN through at least 2
levels of subprocesses (which is asking a lot!).
--
Ethan A Merritt

Hans-Bernhard Broeker

unread,
May 12, 2003, 9:13:56 AM5/12/03
to
Dan Jacobson <jid...@dman.ddts.net> wrote:

> Using emacs -eval '(compile "make")'
> With: echo "plot 'file';pause -1"|gnuplot -persist
> just flashes the graph for a split second.

So let's get into dissecting this further. The first candidate to
remove is 'make'. It doesn't really do anything useful in this whole
setup, so we might as well get rid of it. Let's replace it by a shell
script doing the same things. And while at it, let's get rid of the
separate data file, too:

--- gpaction ---
gnuplot -persist <<EOS
plot '-'
1 1
2 2
e
EOS
---- end ---

sh gpaction # does the plot and returns
emacs -eval '(compile "sh gpaction")' # doesn't plot, but returns
emacs -eval '(shell-command "sh gpaction")' # plot, but no return

For the latter, emacs is unresponsive --- it's obviously waiting for
something to happen, which doesn't. Only after you terminate the
gnuplot graph window (key 'q' into it), or press Ctrl-G in emacs to
forcibly break out of the wait loop, it will continue.

During that pause, look at the output from 'ps jx' and you'll find
that gnuplot_x11 is an orphan --- i.e. it's the only surviving process
in its process group. In "shell-command", emacs apparently doesn't
kill it, whereas in "compile", it probably does.

Dave Denholm

unread,
May 12, 2003, 6:20:42 PM5/12/03
to
mer...@u.washington.edu (Ethan Merritt) writes:

> In article <87d6iqh...@jidanni.org>,
> Dan Jacobson <jid...@dman.ddts.net> wrote:

> >emacs -eval '(compile "make")' #doesn't plot anything.
> >emacs -eval '(shell-command "make&")' #doesn't plot anything
> >emacs -eval '(shell-command "make")' #works wonderfully
> >make #works fine
> >

> This seems to indicate a misunderstanding of emac's handling of

> shell creation rather than anything specific to gnuplot.
> Perhaps you would do better to ask in an emacs forum?
>
> It may even be a machine-specific configuration issue. On my machine

I did look into this a while back - maybe there's something still
in the archives.

I think it was something like emacs is waiting for all file handles
to be closed, rather than for the death of the child process,
or something along those lines.

More weirdness :

compile: echo test | strace -f gnuplot persist

does produce a plot window, but without the strace I don't see it.

compile: { echo test ; sleep 1 ; } | gnuplot -persist
seems to work

Sorry, can't remember the details.

dd
--
Dave Denholm <dden...@esmertec.com> http://www.esmertec.com

Dan Jacobson

unread,
May 15, 2003, 1:37:00 AM5/15/03
to
Gentlemen, RMS himself is asking for analysis of the problem. Please
CC them to bug-gn...@gnu.org

>>>>> "RMS" == Richard Stallman <r...@gnu.org> writes:

Dan> Fellas, the gnuplot team may have found ugly emacs process bugs, see
Dan> http://groups.google.com/groups?threadm=b9o6mk$4q1$1%40nets3.rz.RWTH-Aachen.DE

RMS> Can you ask them to please send us bug reports?
--
http://jidanni.org/ Taiwan(04)25854780

0 new messages