Fixed bug on emacs 24.3+, added condition to use window--display-buffer in newer emacs versions