  More and more applications require semiconductor lasers distinguished not
only by large modulation bandwidths or high output powers, but also by small
spectral linewidths. The theoretical understanding of the root causes limiting
the linewidth is therefore of great practical relevance. In this paper, we
derive a general expression for the calculation of the spectral linewidth step
by step in a self-contained manner. We build on the linewidth theory developed
in the 1980s and 1990s but look from a modern perspective, in the sense that we
choose as our starting points the time-dependent coupled-wave equations for the
forward and backward propagating fields and an expansion of the fields in terms
of the stationary longitudinal modes of the open cavity. As a result, we obtain
rather general expressions for the longitudinal excess factor of spontaneous
emission ($K$-factor) and the effective $\alpha$-factor including the effects
of nonlinear gain (gain compression) and refractive index (Kerr effect), gain
dispersion and longitudinal spatial hole burning in multi-section cavity
structures. The effect of linewidth narrowing due to feedback from an external
cavity often described by the so-called chirp reduction factor is also
automatically included. We propose a new analytical formula for the dependence
of the spontaneous emission on the carrier density avoiding the use of the
population inversion factor. The presented theoretical framework is applied to
a numerical study of a two-section distributed Bragg reflector laser.
