Basically, Nic shortened the text from Scott's Minstrelsy, modernising and anglicising it at the same time. The tune I don't know about; it sounds little like the three variants that have survived, so he probably came up with it himself or adapted a tune from elsewhere.