In 'Non-abelian Bosonization in Two Dimensions', Witten shows that the Poisson brackets of the currents that generate the $G\times G$ symmetry of the WZW model give rise to a Kac-Moody algebra upon canonical quantization.
The Poisson brackets are calculated on page 465 to be \begin{equation} \begin{aligned} \left[X,Y\right]_{PB}&=-\frac{\hbar}{2}\delta'(\sigma-\sigma')\textrm{Tr}~g^{-1}(\sigma)Ag(\sigma)g^{-1}(\sigma')Bg(\sigma') \\&=-\frac{\hbar}{2}\delta(\sigma-\sigma')\textrm{Tr}\bigg([A,B]\frac{\partial g}{\partial\sigma}g^{-1}\bigg)-\frac{\hbar}{2}\delta'(\sigma-\sigma')\textrm{Tr}~AB. \end{aligned}\tag{29} \end{equation} for $X=\textrm{Tr} A \frac{\partial g}{\partial \sigma}g^{-1}(\sigma)$ and $Y=\textrm{Tr} B \frac{\partial g}{\partial \sigma'}g^{-1}(\sigma')$, where $g$ is a map $g:\mathbb{R}\rightarrow G$, and where $A$ and $B$ are arbitrary generators of $G$.
My question is, how does one go from the first line to the second line?
In my attempts so far, I am unable to obtain the second term of the second line. To be precise, starting from the first line above, writing $\delta'(\sigma-\sigma')$ as $\frac{\partial}{\partial \sigma}\delta(\sigma-\sigma')$, and using partial differentiation (and dropping the boundary term), one arrives at \begin{equation} \begin{aligned} \left[X,Y\right]_{PB}=&-\frac{\hbar}{2}\delta(\sigma-\sigma')\textrm{Tr}~g^{-1}(\sigma)\frac{\partial g}{\partial\sigma}(\sigma)g^{-1}(\sigma)Ag(\sigma)g^{-1}(\sigma')Bg(\sigma')\\&+\frac{\hbar}{2}\delta(\sigma-\sigma')\textrm{Tr}~g^{-1}(\sigma)A\frac{\partial g}{\partial\sigma}(\sigma)g^{-1}(\sigma')Bg(\sigma')\\=&-\frac{\hbar}{2}\delta(\sigma-\sigma')\textrm{Tr}\bigg([A,B]\frac{\partial g}{\partial\sigma}(\sigma)g^{-1}(\sigma)\bigg), \end{aligned} \end{equation} which is only the first term of the expression we want. It seems like allowing $A$ and $B$ to have dependence on $\sigma$ may give us the remaining term, but this is not correct, as Witten states explicitly that $A$ and $B$ are matrices on page 462.