withr 2.5.0
-
defer()
and alllocal_*()
functions now work when run inside of
a.Rmd
. The deferred expressions are executed when knitr exits. -
defer()
andlocal_
functions now work withinsource()
.
The deferred expressions are executed whensource()
exits. -
with_()
andlocal_()
gain aget
argument. Supply a getter
function to createwith
andlocal
functions that are robust to
early exits.When supplied, this restoration pattern is used:
old <- get() on.exit(set(old)) set(new) action()
Instead of:
old <- set(new) on.exit(set(old)) action()
This ensures proper restoration of the old state when an early exit
occurs duringset()
(for instance when a deprecation warning is
caught, see #191). -
These
with_
andlocal_
functions are now robust to early exits (see next bullet):_locale()
_envvar()
_libpaths()
_options()
_par()
_path()
_seed()
-
with_namespace()
andlocal_namespace()
now passwarn.conflicts
toattach()
(@kyleam, #185). -
local_rng_version()
andlocal_seed()
no longer warn when
restoringsample.kind
to"Rounding"
(#167). -
with_seed()
now preserves the current values ofRNGkind()
(#167). -
with_collate()
is no longer affected by theLC_COLLATE
environment variable set to "C" (#179). -
Local evaluations in the
globalenv()
(as opposed to top-level
ones) are now unwound in the same way as regular environments. -
local_tempfile()
gains a lines argument so, if desired, you can pre-fill
the temporary file with some data.