Backport defvar-local from Emacs 24.2

Makes the code shorter and simpler IMO.