diff options
author | Case Duckworth | 2021-01-02 22:50:02 -0600 |
---|---|---|
committer | Case Duckworth | 2021-01-02 22:50:02 -0600 |
commit | 5b78ae2ec9fc4a21d442c18a9fa794f9e921e00f (patch) | |
tree | 445efe7db26850b726dcb5eeb5016f891295df8f | |
parent | Kill current buffer (diff) | |
download | emacs-5b78ae2ec9fc4a21d442c18a9fa794f9e921e00f.tar.gz emacs-5b78ae2ec9fc4a21d442c18a9fa794f9e921e00f.zip |
Add a timer to recentf-mode
Autosave the recentf-list, but only when no Emacs frame is focused.
-rw-r--r-- | config.org | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/config.org b/config.org index 0fa3911..eed895a 100644 --- a/config.org +++ b/config.org | |||
@@ -799,12 +799,19 @@ from [[https://www.reddit.com/r/emacs/comments/km9by4/weekly_tipstricketc_thread | |||
799 | (recentf-mode +1) | 799 | (recentf-mode +1) |
800 | 800 | ||
801 | ;; save recentf list when focusing away | 801 | ;; save recentf list when focusing away |
802 | (defun acdw/save-recentf-when-nonfocused () | 802 | (defun acdw/maybe-save-recentf () |
803 | "Save `recentf-file' when out of focus." | 803 | "Save `recentf-file' when out of focus, but only if we haven't |
804 | (acdw/when-unfocused #'recentf-save-list)) | 804 | in five minutes." |
805 | (defvar recentf-last-save (time-convert nil 'integer) | ||
806 | "How long it's been since we last saved the recentf list.") | ||
807 | |||
808 | (when (> (time-convert (time-since recentf-last-save) 'integer) | ||
809 | (* 60 5)) | ||
810 | (setq recentf-last-save (time-convert nil 'integer)) | ||
811 | (acdw/when-unfocused #'recentf-save-list))) | ||
805 | 812 | ||
806 | (add-function :after after-focus-change-function | 813 | (add-function :after after-focus-change-function |
807 | #'acdw/save-recentf-when-nonfocused) | 814 | #'acdw/maybe-save-recentf) |
808 | #+END_SRC | 815 | #+END_SRC |
809 | 816 | ||
810 | ** Undo | 817 | ** Undo |