Emacs org-mode gnuplot : Error running timer: (void-variable data-file)

1.3k views Asked by At

Whenever I call the command org-plot/gnuplot in emacs org-mode, I get the same error Error running timer: (void-variable data-file). I am using emacs 24.4.1 in Debian Jessie as well as emacs 24.5 on a Mac Os. Both systems have a working version of gnuplot. I even try this command when running emacs with no .emacs files and still get this same error.

2

There are 2 answers

0
Kalman Reti On

It is a bug. The function org-plot/gnuplot (in org-plot.el) hasn't yet been updated to account for lexically-scoped variables. You can fix it in your emacs installation (assuming you have the .el files installed) by first finding the org-plot.el source file (one way is to do

m-x apropos ^org-plot/gnuplot$ 

and then clicking on the file link at the top of the result) and replacing the last expression in the org-plot/gnuplot function (use c-m-f to get to the end quickly)

(run-with-idle-timer 0.1 nil (lambda () (delete-file data-file)))

to instead read

(run-with-idle-timer 0.1 nil (lambda (data-file) (delete-file data-file)) data-file)

The original code was expecting the lambda to close over the dynamic data-file variable, but it is now lexical. My replacement code passes the value directly into the lambda.

You will have to save the modified file and then recompile it with

m-x byte-compile-file

or you'll just see a warning that the .el file is newer (but it will load the .elc with the old code anyway).

I wouldn't be surprised if this is fixed in newer versions of org, but I haven't checked.

0
djhaskin987 On

EDIT: Found it! See original answer below. In it, I find the line which refers to data-file. The comments in the original source file around that line mention that changes were made to accomodate gnuplot 4. That, together with @vu-nguyen's comment, led me to download and compile gnuplot 4.6.7 .

I compiled and installed it thus:

./configure --with-cwdrc --with-readline=gnu --enable-backwards-compatibility
make
sudo make install

And it started working.

Original Answer

I deleted my elpa folder and reinstalled my elpa packages to make sure I wasn't using "dirty" package folders. EDIT: I even uninstalled the newest version of the gnuplot package and installed older versions (20140317 and 0.6.6) but nothing helped.

It looks like the only package that talks about data-file is gnuplot:

gnuplot.el:2820: ("(gnuplot)data-file" nil "[_a-zA-Z0-9]+")

Maybe it is a bug?