Using a small frying pan, lightly toast the pine nuts over medium-low heat for 3 to 5 minutes, shaking the pan back and forth to keep them from scorching. Set aside.
Peel the onions—either by blanching them first in boiling, salted water for about 30 seconds and then using a sharp paring knife to strip away the skins, or by simply going at the raw onions with the aforementioned paring knife.
Put the olive oil in large frying pan over medium-low heat. Add the onions and cook gently (without browning) for about 5 minutes. Add the sherry and cook until mostly reduced. Add 3/4 cup water, vinegar, sugar, raisins, pine nuts and a pinch of salt. Stir well. Simmer the mixture over the lowest heat possible for 1 1/2 to 2 hours, stirring every 15 minutes or so. You may need to add more water from time to time if the mixture gets too thick and gooey or starts to stick to the bottom of the pan. It is finished when everything has caramelized well, and the flavors have blended together.
Cool and serve at room temperature. This can, and really should, be made ahead of time, as the flavors develop in complexity after a day or two. The confit will keep refrigerated for up to 2 weeks.