The group-function theory, as proposed by McWeeny for the study of weak intermolecular interactions and developed by Huzinaga in the context of valence-electron methods, is shown to be applicable to the ab initio study of tunable solid-state laser materials made of defective ionic crystals. The applicability of the theory relies on the existence of local electronic states (to which the demonstrated/potential laser activity is ascribed), which are essentially localized in a small cluster of atoms including the defect and whose electron correlation interactions with the surrounding crystal components are negligible. According to the group-function formalism, it is possible (a) to neglect electron correlation effects beyond the defect cluster and (b) to define a quantum mechanical embedding potential which embodies the rest of the so-called host effects. Computationally, the theory becomes applicable as the embedding potential is approximated through ab initio model potentials (AIMP). The results of AIMP embedded-cluster calculations demonstrate that it is possible to calculate the local structure and spectroscopy of the active defect at an ab initio level, the attainable accuracy being comparable to the usual one in molecular ab initio studies in the gas phase. Also, in this article, we present a systematic study of the local distortions produced upon doping divalent first-series transition-metal ions in rock-salt oxides, MOMe2+ (M=Mg, Ca, Sr; Me=Sc-Zn) and TIt in KMgF, and KF hosts. This study leads to the calculation of the local structures of the defects in these materials, which have not been measured. The results suggest that the use of the mismatch of the empirical ionic radii of the impurity and the substituted ion in order to pre$ct local distortions in doped ionic crystals is not significant when it is smaller than 0.1 A, and when it is larger, it should be weighted by a reduction factor depending on the host. For the first-series divalent transition-metal ion impurities, this factor is shown to be 0.15 for SrO, 0.25 for CaO, and around 0.50 for MgO.