  We report a novel method for evaluating the energy spectrum of electrons
emitting hard x-rays and gamma-rays in undulators and Compton sources. The
method takes into account the quantum nature of recoils undergone by the
electrons emitting high energy photons. The method is susceptible to evaluate a
spectrum of electrons for the whole range of the emission rates per
electron-pass through of the driving force, from much less than one emitted
photon on average (Compton sources and short undulators) to many emitted
photons (long undulators, relatively low-energy electrons). As shown in the
former limiting case, the spectrum of electrons reflects the spectrum of
emitted radiation whereas it is close to the Gaussian shape in the latter case.
Limitation of coherency for the sources of high-energy electromagnetic
radiation caused by recoils from emitted photons is also discussed.
