  The spectral function related to the correlator of two colour-electric fields
along a Polyakov loop determines the momentum diffusion coefficient of a heavy
quark near rest with respect to a heat bath. We compute this spectral function
at next-to-leading order, O(alpha_s^2), in the weak-coupling expansion. The
high-frequency part of our result (omega >> T), which is shown to be
temperature-independent, is accurately determined thanks to asymptotic freedom;
the low-frequency part of our result (omega << T), in which Hard Thermal Loop
resummation is needed in order to cure infrared divergences, agrees with a
previously determined expression. Our result may help to calibrate the overall
normalization of a lattice-extracted spectral function in a perturbative
frequency domain T << omega << 1/a, paving the way for a non-perturbative
estimate of the momentum diffusion coefficient at omega -> 0. We also evaluate
the colour-electric Euclidean correlator, which could be directly compared with
lattice simulations. As an aside we determine the Euclidean correlator in the
lattice strong-coupling expansion, showing that through a limiting procedure it
can in principle be defined also in the confined phase of pure Yang-Mills
theory, even if a practical measurement could be very noisy there.
