Please try the attached patch - it's based on Stefan's suggestion to use `handle-select-window'. martin.