I want to calculate the integral
$$F=\int \sum_{m=-\infty}^\infty e^{im(\varphi-\varphi')} \cos(p\varphi') \, d\varphi'$$
In this case I must assume that $m$ and $n$ are integers. As I understand to perform this integral I must transform the cosine function into exponential and then integrate. In this way I obtain that:
$$F=\pi\cos(p\varphi)$$
Is there a problem in what has been done?
\begin{align} & \int_0^{2\pi} \sum_{m=-\infty}^\infty e^{im(\varphi-\varphi')} \cos(p\varphi') \, d\varphi' = \int_0^{2\pi} \sum_{m=-\infty}^\infty e^{im(\varphi-\varphi')} \frac 1 2 \left(e^{ip\varphi'} + e^{-ip\varphi'} \right) \, d\varphi' \\[10pt] = {} & \frac 1 2 \sum_{m=-\infty}^\infty e^{im\varphi} \int_0^{2\pi} \left( e^{-i \varphi'(m-p)} + e^{-i\varphi'(m+p)} \right) \, d\varphi' \tag 1 \end{align}
\begin{align} & \int_0^{2\pi} e^{-i\varphi'(m-p)} \, d\varphi' = \begin{cases} 0 & \text{when } m\ne p, \\ 2\pi & \text{when } m=p. \end{cases} \\[5pt] & \int_0^{2\pi} e^{-i\varphi'(m+p)} \, d\varphi' = \begin{cases} 0 & \text{when } m\ne -p, \\ 2\pi & \text{when } m=-p. \end{cases} \end{align}
So line $(1)$ above becomes $$ \frac 1 2 \left( e^{ip\varphi} \cdot 2\pi + e^{-ip\varphi} \cdot 2\pi \right) = 2\pi \cos(p\varphi). $$
You have $\pi$ where I have $2\pi,$ so the question for both of us now is which if either is right.
The above assumes $p\ne0,$ i.e. $p$ and $-p$ are two different numebers, so one would look at the case $p=0$ separately.