For the second time in his life, John Swinney is elected leader of the SNP in difficult circumstances.