6.19 withr::defer()can defer events on the global environment

Deferred events can be set on the global environment to facilitate the interactive development of code that is intended to be executed inside a function or test.

A message alerts the user to the fact that an explicit deferred_run() is the only way to trigger these deferred events.

defer(print("hi"))
#> Setting deferred event(s) on global environment.
#>   * Execute (and clear) with `withr::deferred_run()`.
#>   * Clear (without executing) with `withr::deferred_clear()`.

pi
#> [1] 3.141593

# this adds another deferred event, but does not re-message
local_digits(3)

pi
#> [1] 3.14

deferred_run()
#> [1] "hi"

pi
#> [1] 3.141593