Diagonally cut baguette crosswise into 3/4-inch thick slices and brush both sides with butter. Toast on a baking sheet under broiler 3 inches from heat until golden, about 30 seconds on each side. Preheat oven to 350 degrees.
Cook onions in oil in a 12-inch nonstick skillet over moderately high heat, stirring occasionally, until golden. Add ham and cook, stirring occasionally, until ham is lightly browned.
Whisk eggs in a large bowl and whisk in milk, salt, nutmeg, and pepper. Add toasted bread and toss gently. When the bread is saturated, transfer it to a shallow 3-quart casserole, slightly overlapping slices. Add any remaining egg mixture.
Tuck spinach and ham between slices, reserving a little ham to sprinkle over top. Sprinkle cheese over pudding, lifting slices with a spatula to allow some to fall between them. Sprinkle reserved ham over pudding and bake in middle of oven until puffed and edges of bread are golden and custard is set in middle, about 45 minutes to 1 hour.