Port backspace/delete handling from IMP's prettyautocompleter.