From 8294615d33a2a4849ed4f17596b0ef14e043bad9 Mon Sep 17 00:00:00 2001 From: YongHee Kim Date: Wed, 15 Feb 2017 10:59:11 +0900 Subject: [PATCH] Set limit for number of temporary files This is for #645 I think problem is that `Plots.jl` can potentially create several hundred temporary files, not that really matters... but just messy. And since Juno Plot Pane is planning to introduce [plot history feature](https://github.com/JunoLab/atom-julia-client/issues/122) sometime in the future. So it makes sense to store 'some' temporary files and make those names predictable for Juno Plot Pane to handle history. --- src/output.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/output.jl b/src/output.jl index f3efd812..7d69e732 100644 --- a/src/output.jl +++ b/src/output.jl @@ -117,7 +117,15 @@ function savefig(plt::Plot, fn::AbstractString) end savefig(fn::AbstractString) = savefig(current(), fn) - +function Base.tempname() + tempfile_limit = UInt32(30) + global tempname_counter = if isdefined(Plots, :tempname_counter) + tempname_counter + UInt32(1) + else + UInt32(1) + end + return tempname(tempname_counter % tempfile_limit) +end # --------------------------------------------------------- gui(plt::Plot = current()) = display(PlotsDisplay(), plt)