Interaction of capillary waves with longer waves. Part 1. General theory and specific applications to waves in one dimension