Emacs で最近開いたファイルのリストを自動保存する。 - 日々、とんは語る。
anything.el との組み合わせが素敵すぎますね。ずっと便利に使ってます。
ただ、ミニバッファに 30 秒ごとに “Wrote ~/.emacs.d/.recentf” と表示
されるのが結構気になっていました。なので、メッセージを表示しないよ
うに、且つ必要時以外は recentf-save-file に保存しないようにしました。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(defvar my-recentf-list-prev nil) | |
(defadvice recentf-save-list | |
(around no-message activate) | |
"If `recentf-list' and previous recentf-list are equal, | |
do nothing. And suppress the output from `message' and | |
`write-file' to minibuffer." | |
(unless (equal recentf-list my-recentf-list-prev) | |
(cl-flet ((message (format-string &rest args) | |
(eval `(format ,format-string ,@args))) | |
(write-file (file &optional confirm) | |
(let ((str (buffer-string))) | |
(with-temp-file file | |
(insert str))))) | |
ad-do-it | |
(setq my-recentf-list-prev recentf-list)))) | |
(defadvice recentf-cleanup | |
(around no-message activate) | |
"suppress the output from `message' to minibuffer" | |
(cl-flet ((message (format-string &rest args) | |
(eval `(format ,format-string ,@args)))) | |
ad-do-it)) | |
(setq recentf-save-file (expand-file-name ".recentf" user-emacs-directory)) | |
(setq recentf-max-saved-items 2000) | |
(setq recentf-exclude '(".recentf")) | |
(setq recentf-auto-cleanup 10) | |
(run-with-idle-timer 30 t 'recentf-save-list) | |
(recentf-mode 1) |
設定は @tomoyaton
さんの記事と重複してますが、分かりづらくなるので
私の recentf 関連の設定を全て記載しています。recentf-save-file をデ
フォルトの ~/.recentf から ~/.emacs.d/.recentf にも変更しています。
@cvmat
さんにはいろいろというか、ほぼ全てのアドバイスを頂きました。
いつもありがとうございます。
追記(2011-10-30):
コメント欄でよりシンプルな方法を教えて頂いたので、コードを差し替え
ました。