How to hold residual-dependent term constant in Jacobian calculation


This is a pretty general question related to this post I am implementing a viscosity discontinuity capturing term.

My question is how do I hold a residual-dependent variable constant during the Jacobian calculation? If say
J = ufl.derivative(Res, u)
where the residual is
Res = Res_Gal + Res_Stab
and the term in question is say NU in
Res_Stab = ufl.inner(NU * ufl.grad(w), ufl.grad(u))*dx
is a function of
StrongResidual = SomeFunction(u).