Commit ab29f0e57563

Vincent Demeester <vincent@sbr.pm>
2020-02-27 18:47:03
Configure recentf before loading recentf ๐Ÿ˜…
And have `recentf-auto-cleanup` to run after 360s of idle time (value to refine later I guess) instead of `mode`.. Otherwise it would get really slow at startup depending on what was in the `recentf` history. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 6aa8829
config/00-clean.el
@@ -1,3 +1,50 @@
+(use-package recentf
+  :custom
+  (recentf-max-menu-items 15)
+  (recentf-max-saved-items 200)
+  (recentf-auto-cleanup 360)
+  (recentf-show-file-shortcuts-flag nil)
+  :config
+  (recentf-mode 1)
+  (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
+  ;; Magic advice to rename entries in recentf when moving files in
+  ;; dired.
+  (defun rjs/recentf-rename-notify (oldname newname &rest args)
+    (if (file-directory-p newname)
+        (rjs/recentf-rename-directory oldname newname)
+      (rjs/recentf-rename-file oldname newname)))
+
+  (defun rjs/recentf-rename-file (oldname newname)
+    (setq recentf-list
+          (mapcar (lambda (name)
+                    (if (string-equal name oldname)
+                        newname
+                      oldname))
+                  recentf-list))
+    recentf-cleanup)
+
+  (defun rjs/recentf-rename-directory (oldname newname)
+    ;; oldname, newname and all entries of recentf-list should already
+    ;; be absolute and normalised so I think this can just test whether
+    ;; oldname is a prefix of the element.
+    (setq recentf-list
+          (mapcar (lambda (name)
+                    (if (string-prefix-p oldname name)
+                        (concat newname (substring name (length oldname)))
+                      name))
+                  recentf-list))
+    recentf-cleanup)
+
+  (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify)
+
+  (defun contrib/recentf-add-dired-directory ()
+    "Include Dired buffers in the list.  Particularly useful when
+combined with a completion framework's ability to display virtual
+buffers."
+    (when (and (stringp dired-directory)
+               (equal "" (file-name-nondirectory dired-directory)))
+      (recentf-add-file dired-directory))))
+
 (use-package no-littering               ; Keep .emacs.d clean
   :config
   (require 'recentf)
config/setup-files.el
@@ -5,52 +5,6 @@
 (use-package ripgrep
   :defer 2)
 
-(use-package recentf
-  :custom
-  (recentf-max-menu-items 15)
-  (recentf-max-saved-items 200)
-  (recentf-show-file-shortcuts-flag nil)
-  :config
-  (recentf-mode 1)
-  (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
-  ;; Magic advice to rename entries in recentf when moving files in
-  ;; dired.
-  (defun rjs/recentf-rename-notify (oldname newname &rest args)
-    (if (file-directory-p newname)
-        (rjs/recentf-rename-directory oldname newname)
-      (rjs/recentf-rename-file oldname newname)))
-
-  (defun rjs/recentf-rename-file (oldname newname)
-    (setq recentf-list
-          (mapcar (lambda (name)
-                    (if (string-equal name oldname)
-                        newname
-                      oldname))
-                  recentf-list))
-    recentf-cleanup)
-
-  (defun rjs/recentf-rename-directory (oldname newname)
-    ;; oldname, newname and all entries of recentf-list should already
-    ;; be absolute and normalised so I think this can just test whether
-    ;; oldname is a prefix of the element.
-    (setq recentf-list
-          (mapcar (lambda (name)
-                    (if (string-prefix-p oldname name)
-                        (concat newname (substring name (length oldname)))
-                      name))
-                  recentf-list))
-    recentf-cleanup)
-
-  (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify)
-
-  (defun contrib/recentf-add-dired-directory ()
-    "Include Dired buffers in the list.  Particularly useful when
-combined with a completion framework's ability to display virtual
-buffers."
-    (when (and (stringp dired-directory)
-               (equal "" (file-name-nondirectory dired-directory)))
-      (recentf-add-file dired-directory))))
-
 (setq view-read-only t)                 ; View read-only
 
 (use-package direnv
emacs.org
@@ -499,6 +499,53 @@
 Let's configure it *and* make sure we load it as soon as possible (hence the =config/00-clean.el=)
 
 #+begin_src emacs-lisp
+(use-package recentf
+  :custom
+  (recentf-max-menu-items 15)
+  (recentf-max-saved-items 200)
+  (recentf-auto-cleanup 360)
+  (recentf-show-file-shortcuts-flag nil)
+  :config
+  (recentf-mode 1)
+  (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
+  ;; Magic advice to rename entries in recentf when moving files in
+  ;; dired.
+  (defun rjs/recentf-rename-notify (oldname newname &rest args)
+    (if (file-directory-p newname)
+        (rjs/recentf-rename-directory oldname newname)
+      (rjs/recentf-rename-file oldname newname)))
+
+  (defun rjs/recentf-rename-file (oldname newname)
+    (setq recentf-list
+          (mapcar (lambda (name)
+                    (if (string-equal name oldname)
+                        newname
+                      oldname))
+                  recentf-list))
+    recentf-cleanup)
+
+  (defun rjs/recentf-rename-directory (oldname newname)
+    ;; oldname, newname and all entries of recentf-list should already
+    ;; be absolute and normalised so I think this can just test whether
+    ;; oldname is a prefix of the element.
+    (setq recentf-list
+          (mapcar (lambda (name)
+                    (if (string-prefix-p oldname name)
+                        (concat newname (substring name (length oldname)))
+                      name))
+                  recentf-list))
+    recentf-cleanup)
+
+  (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify)
+
+  (defun contrib/recentf-add-dired-directory ()
+    "Include Dired buffers in the list.  Particularly useful when
+combined with a completion framework's ability to display virtual
+buffers."
+    (when (and (stringp dired-directory)
+               (equal "" (file-name-nondirectory dired-directory)))
+      (recentf-add-file dired-directory))))
+
 (use-package no-littering               ; Keep .emacs.d clean
   :config
   (require 'recentf)
@@ -2505,52 +2552,6 @@
 (use-package ripgrep
   :defer 2)
 
-(use-package recentf
-  :custom
-  (recentf-max-menu-items 15)
-  (recentf-max-saved-items 200)
-  (recentf-show-file-shortcuts-flag nil)
-  :config
-  (recentf-mode 1)
-  (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
-  ;; Magic advice to rename entries in recentf when moving files in
-  ;; dired.
-  (defun rjs/recentf-rename-notify (oldname newname &rest args)
-    (if (file-directory-p newname)
-        (rjs/recentf-rename-directory oldname newname)
-      (rjs/recentf-rename-file oldname newname)))
-
-  (defun rjs/recentf-rename-file (oldname newname)
-    (setq recentf-list
-          (mapcar (lambda (name)
-                    (if (string-equal name oldname)
-                        newname
-                      oldname))
-                  recentf-list))
-    recentf-cleanup)
-
-  (defun rjs/recentf-rename-directory (oldname newname)
-    ;; oldname, newname and all entries of recentf-list should already
-    ;; be absolute and normalised so I think this can just test whether
-    ;; oldname is a prefix of the element.
-    (setq recentf-list
-          (mapcar (lambda (name)
-                    (if (string-prefix-p oldname name)
-                        (concat newname (substring name (length oldname)))
-                      name))
-                  recentf-list))
-    recentf-cleanup)
-
-  (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify)
-
-  (defun contrib/recentf-add-dired-directory ()
-    "Include Dired buffers in the list.  Particularly useful when
-combined with a completion framework's ability to display virtual
-buffers."
-    (when (and (stringp dired-directory)
-               (equal "" (file-name-nondirectory dired-directory)))
-      (recentf-add-file dired-directory))))
-
 (setq view-read-only t)                 ; View read-only
 
 (use-package direnv