Tern-mode

After much mucking around, at last it works mostly the way I wanted.