List recently closed files in Emacs
(require 'recentc)
(recentc-mode 1)
Press C-c C-r
to list recently closed files with ivy-mode
(preferred) or ido-mode
. Press C-c C-u
to open the most recently
closed file.
Customize key bindings:
(define-key recentc-mode-map "\C-x\C-r" #'recentc-find-closed-file)
(define-key recentc-mode-map "\C-x\C-u" #'recentc-reopen-last-closed-file)
Exclude closed files under ~/.emacs.d/
(user-emacs-directory
):
(add-hook 'recentc-exclude-conditions
(lambda (filename)
(string-prefix-p (expand-file-name user-emacs-directory)
(file-name-directory (expand-file-name filename)))))
Exclude closed files in .git
:
(defun pt/folder-name (filename)
(file-name-base (directory-file-name (file-name-directory filename))))
(add-hook 'recentc-exclude-conditions
(lambda (filename)
(string-equal ".git" (pt/folder-name (expand-file-name filename)))))