4. Given that $f(x)$ satisfies
$$
f(x)+f\left(\frac{x-1}{x}\right)=1+x \quad (x \neq 0,1) \text {. }
$$

then the range of $g(x)=x-2 f(x)$ is $\qquad$
4. $(-\infty,-4] \cup(0,+\infty)$.

Let $\varphi(x)=\frac{x-1}{x}$. Then
$$
\begin{array}{l}
\varphi^{2}(x)=\varphi(\varphi(x))=\varphi\left(\frac{x-1}{x}\right)=\frac{1}{1-x}, \\
\varphi^{3}(x)=\varphi\left(\varphi^{2}(x)\right)=\varphi\left(\frac{1}{1-x}\right)=x .
\end{array}
$$

At this point, the condition is expressed as
$$
\begin{array}{l}
f(x)+f(\varphi(x))=1+x \\
\Rightarrow f(\varphi(x))+f\left(\varphi^{2}(x)\right) \\
\quad=1+\varphi(x)=\frac{2 x-1}{x} \\
\Rightarrow f\left(\varphi^{2}(x)\right)+f\left(\varphi^{3}(x)\right)=\frac{2 \varphi(x)-1}{\varphi(x)} \\
\Rightarrow f\left(\varphi^{2}(x)\right)+f(x)=\frac{2-x}{1-x} .
\end{array}
$$

Thus, $2 f(x)=1+x-\frac{2 x-1}{x}+\frac{2-x}{1-x}$
$$
\Rightarrow f(x)=\frac{x^{3}-x^{2}-1}{2 x(x-1)}(x \in \mathbf{R} \backslash\{0,1\}) \text {. }
$$

Verification shows that it satisfies the given equation.
Then $g(x)=\frac{1}{x^{2}-x} \in(-\infty,-4] \cup(0,+\infty)$.