actual working version of revert-buffer-keep-history from stackoverflow