cloned from http://cx4a.org/software/auto-complete/