JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
301 stars 55 forks source link

Adding convenience macro for `with_terminal` #114

Closed cadojo closed 2 years ago

cadojo commented 3 years ago

When I write Pluto notebooks, I nearly always write a cell with...

macro terminal(expr)    
  quote     
    with_terminal() do          
      $(esc(expr))      
    end 
  end
end

This way, to quickly show values I can simply write @terminal print(my_struct). Replacing print with a block of show or print calls also works.

This feels like a pretty unobtrusive addition, and I think it makes for a nice convenience wrapper for the with_terminal function. I figured I'd post it here in case it was useful. Feel free to toss this!

fonsp commented 2 years ago

Hey @cadojo ! Sorry for the extremely late response! It looks like dralletje also wanted the same, and left the code ready: https://github.com/JuliaPluto/PlutoUI.jl/commit/9948cb4f30cfabb3f98f376a84395d57ff256004

Thanks for the suggestion!