ClearAll[evalWithFrozenSyms]
SetAttributes[evalWithFrozenSyms, HoldAll];
evalWithFrozenSyms[expr_, unfrozen : {___Symbol} : {},
wrapper_: Hold, getsymbolsF_: getHeldSymbols
] :=
With[{frozen =
Thread[
Complement[
getsymbolsF[expr],
Thread[HoldComplete[unfrozen]]
],
HoldComplete
]
},
If[ReleaseHold[frozen]If[frozen ===== {}, expr,
frozen /. HoldComplete[{syms___}] :>
Block[{syms}, wrapper[##] &@expr]
]
]