Search code examples
juliajuno-ide

Clean workspace, plot pane, and console on rerun in Julia


I am used to starting all my Matlab scripts with clear all; close all; clc to ensure I am not looking at any old data or plots. I found Julia's clearconsole() to be equivalent to Matlab's clc, but don't have working solutions for the other two Matlab commands yet. I mostly work in the Juno IDE and run scripts with the Play ("Run All") button.

The Revise.jl package is supposed to clear the workspace now that workspace() is deprecated, but it doesn't work for this simple test case. If I define x once and then comment that line out, it will continue to print each time I run without error.

using Revise
clearconsole()
#x=1
println(x)

I know I can hit "Stop" then "Play" to reset the workspace. However, that still doesn't close old plots, and the time to first plot issue makes this option undesirable.

I found the "Forget All Plots" button in Juno's plot pane, but I would like to have that functionality as a line in my script instead. Currently, it takes me three clicks to run a script again after I edit it (four if I include "Stop").

  1. "Forget All Plots"
  2. Somewhere in the editor to put focus back on my current file.
  3. "Run All"

I would ideally like to rerun in a fresh environment with one click or keystroke, but any tips on a better Juno workflow would be appreciated.


Solution

  • My question was answered on the Julia discourse website: link.

    • Juno.clearconsole() may be used like Matlab's clc.
    • Writing a script within a module will clear the variables upon each run like Matlab's clear all.
    • A new function may be added to Juno.jl in the future which will work like Matlab's close all.