瀏覽代碼

org-plot: Correction in callback registration

org-plot.el (org-plot/gnuplot): Correct the callback for the and
register it as soon as possible.

The data-file variable is not in the scope of the callback, one needs
to grab its value while registering the callback.  With this patch the
timer is set as soon as the file is created.  Without this patch the
timer is set at the end of a let-block, if anything goes wrong in the
let-block before the timer is set, the file will not be removed.

TINYCHANGE
Mario Frasca 10 年之前
父節點
當前提交
4c37a937a7
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lisp/org-plot.el

+ 2 - 2
lisp/org-plot.el

@@ -294,6 +294,7 @@ line directly before or after the table."
 	   (table (org-table-to-lisp))
 	   (num-cols (length (if (eq (first table) 'hline) (second table)
 			       (first table)))))
+      (run-with-idle-timer 0.1 nil #'delete-file data-file)
       (while (equal 'hline (first table)) (setf table (cdr table)))
       (when (equal (second table) 'hline)
 	(setf params (plist-put params :labels (first table))) ;; headers to labels
@@ -344,8 +345,7 @@ line directly before or after the table."
 	(gnuplot-mode)
 	(gnuplot-send-buffer-to-gnuplot))
       ;; cleanup
-      (bury-buffer (get-buffer "*gnuplot*"))
-      (run-with-idle-timer 0.1 nil (lambda () (delete-file data-file))))))
+      (bury-buffer (get-buffer "*gnuplot*")))))
 
 (provide 'org-plot)