What is the reason this proof of pointwise convergence for the Fourier series fails? Most proofs I found for the pointwise convergence of the Fourier series
finishes by applying the Riemann-Lebesgue Lemma which states that if $f$ is a Riemann integrable function over $[a,\ b]$, then:
$$
\lim_{\mu \to \infty} \int_{a}^{b} f(u)\cos(\mu u)du=0
$$
Now since the Dirichlet kernel is even and $2\pi$ periodic given ANY interval of this length it holds:
$$
\frac{1}{\pi} \int_{x-\pi}^{x+\pi}D_N(u)du=1
$$
So multiplying by arbitrary $f(x)$:
$$
f(x) = \frac{1}{\pi} \int_{x-\pi}^{x+\pi} f(x)D_N(u)du
$$
Then we know the following form of the $N$th Fourier partial sum:
$$
S_N(x) = \frac{1}{\pi}\int_{-\pi}^{\pi}f(u)D_N(x-u)du
$$
Then we make the substitution $u = x - t$ and we obtain:
$$
S_N(x)=-\frac{1}{\pi}\int_{x+\pi}^{x-\pi}f(x - t)D_N(t)dt=\frac{1}{\pi}\int_{x-\pi}^{x+\pi}f(x-t)D_N(t)dt
$$
Then usally we are told that since we assume $f$ to be $2 \pi$ periodic this latter integral is:
$$
\frac{1}{\pi}\int_{-\pi}^{\pi}f(x-t)D_N(t)dt
$$
But I thought, what if I did not require $f$ to be periodic?
Then for the difference $f(x) - S_N(x)$ we obtain:
$$
\frac{1}{\pi}\int_{x-\pi}^{x+\pi}(f(x) - f(x - t))D_N(t)dt
$$
Then we expand the Dirichlet kernel to its closed form so that we can apply the Riemann Lebesgue Lemma:
$$
f(x)-S_N(x)=\frac{1}{\pi}\int_{x-\pi}^{x+\pi}(f(x) - f(x - t))\frac{\sin((N + \frac{1}{2})t)}{2\sin(\frac{t}{2})}dt
$$
Some little rearrangement:
$$
\frac{1}{\pi}\int_{x-\pi}^{x+\pi}\frac{f(x) - f(x - t)}{2\sin(\frac{t}{2})}(\sin(Nt)\cos(\frac{t}{2}) + \cos(Nt)\sin(\frac{t}{2}))dt
$$
And finally we split the integral into 2:
$$
\frac{1}{\pi}\int_{x-\pi}^{x+\pi} \frac{f(x) - f(x - t)}{2}\cos(Nt)dt+ \frac{1}{\pi}\int_{x-\pi}^{x+\pi} \frac{(f(x) - f(x - t))\cos(\frac{t}{2})}{2\sin(\frac{t}{2})}\sin(Nt)dt
$$
And principally, this formula is indeed true for $f(x) - S_N(x)$.
To obtain it, I never ever had to use such information that $f$ should be $2\pi$ periodic. That being said, in this form, I can not state that, by the Riemann-Lebesgue Lemma, the two integrals tend to zero? That would be false since the Fourier series is periodic by nature and is said to converge to a periodic extension of $f$.
The original proof eliminates the $x$ in the bounds of the integral.
As I have mentioned, that is ONLY possible if $f$ is $2\pi$ periodic. But
in no other step of the proof it seems evident that $f$ must be periodic.
So we get in the original proof:
$$
\frac{1}{\pi}\int_{-\pi}^{\pi} \frac{f(x) - f(x - t)}{2}\cos(Nt)dt + \frac{1}{\pi}\int_{-\pi}^{\pi} \frac{(f(x) - f(x - t))\cos(\frac{t}{2})}{2\sin(\frac{t}{2})}\sin(Nt)dt
$$
Then the proof shows that in both of the integrals the integrand is differentiable and
due to the Riemann-Lebesgue Lemma the two integrals tend to zero and finishes the proof.
So why is it that for a fixed $x$ I cannot apply the lemma in former, but I can apply it in the latter case?
 A: Ignoring the typos where you lost a factor of $\frac{1}{\pi}$ at a few stages, everything is correct until the very end, where you try to apply Riemann-Lebesgue Lemma. The left hand integral does indeed vanish due to this lemma, but the lemma cannot be applied to the right hand integral because it fails the Riemann integrable condition.
Label the function $F(t)=\frac{(f(x)-f(x-t))\cos(\frac{t}{2})}{2\sin(\frac{t}{2})}$, then what we want to say is that:
$$\lim_{N\to\infty}\int_{x-\pi}^{x+\pi}F(t)\sin(Nt)dt = 0$$
This cannot be guaranteed, however. Due to that $\sin(\frac{t}{2})$ in the denominator, $F$ has a singularity whenever $\sin(\frac{t}{2})=0$, which happens whenever $t$ is a multiple of $2\pi$. Since the range of $t$ in the integral is of length $2\pi$, this is guaranteed to occur at least once, no matter what $x$ is. Without imposing other conditions on $f$, we should expect $F$ explode in value when $t$ is near one of these singularities, so $F$ isn't integrable and Riemann-Lebesgue Lemma cannot apply.
This isn't an issue when $x$ is in the interval $(-\pi,\pi)$, since then the only singularity is at $t=0$. At this point, the $f(x)-f(x-t)$ in the numerator is zero, and since $f$ is differentiable, this can cancel out the previously mentioned singularity. This explains why the Fourier series converges to $f$ on the interval $(-\pi,\pi)$, even if $f$ is not periodic. If in addition to the above, $f$ is also $2\pi$ periodic, then the periodicity lets the above resolution extend to all the other singularities, so that $F$ is integrable and Riemann-Lebesgue applies, giving convergence everywhere.
Addendum: As a rule of thumb, typically a theorem (or lemma) will be stated as an implication: If $F$ is Riemann integral, then this limit of integrals converges to zero. If the conclusion of a theorem gives a nonsense result however, you can use the contrapositive to figure out what went wrong: If that  limit of integrals doesn't converge to zero, then it must be that $F$ is not Riemann integrable.
