Sometimes I accidentally kill a buffer and want to reopen it, just like C-S-t to undo closed tab in Firefox, but there is no built-in command in Emacs, the defun undo-kill-buffer
in http://www.emacswiki.org/RecentFiles :
(defun undo-kill-buffer (arg)
"Re-open the last buffer killed. With ARG, re-open the nth buffer."
(interactive "p")
(let ((recently-killed-list (copy-sequence recentf-list))
(buffer-files-list
(delq nil (mapcar (lambda (buf)
(when (buffer-file-name buf)
(expand-file-name (buffer-file-name buf)))) (buffer-list)))))
(mapc
(lambda (buf-file)
(setq recently-killed-list
(delq buf-file recently-killed-list)))
buffer-files-list)
(find-file
(if arg (nth arg recently-killed-list)
(car recently-killed-list)))))
doesn't work at all. If you know elisp, how to solve this problem?
If it can show a list of the closed buffers and them I can choose one from them to reopen, that would be better.