Various enhancements in garbage collection, file-name-handler-alist, and recentf

This commit is contained in:
James Cherti
2025-02-18 15:58:05 -05:00
parent e16fe62722
commit 1293be787c
2 changed files with 16 additions and 21 deletions

View File

@@ -89,9 +89,10 @@ minimalistic appearance during startup.")
(setq gc-cons-threshold most-positive-fixnum)
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold)))
(defun minimal-emacs--restore-gc-cons-threshold ()
"Restore `minimal-emacs-gc-cons-threshold'."
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold))
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105)
;;; Misc
@@ -127,15 +128,17 @@ minimalistic appearance during startup.")
(let ((file-name-handler-alist
(if args-left old-value file-name-handler-alist)))
(funcall fn args-left)))
;; Remember the old value to reset it as needed.
(add-hook 'emacs-startup-hook
(lambda ()
;; Restore the old value to reset it as needed.
(defun minimal-emacs--restore-file-name-handler-alist ()
"Restore `file-name-handler-alist'."
(set-default-toplevel-value
'file-name-handler-alist
;; Merge instead of overwrite to preserve any changes made
;; since startup.
;; Merge instead of overwrite to preserve any changes made since startup.
(delete-dups (append file-name-handler-alist old-value))))
101))
(add-hook
'emacs-startup-hook #'minimal-emacs--restore-file-name-handler-alist 101))
(unless noninteractive
(unless minimal-emacs-debug

10
init.el
View File

@@ -208,15 +208,7 @@
;; recently.
(setq recentf-max-saved-items 300) ; default is 20
(setq recentf-max-menu-items 15)
(setq recentf-auto-cleanup (if (daemonp) 300 'never))
(defun minimal-emacs--cleanup-hook ()
"Run `recentf-cleanup' if `recentf' is loaded and `recentf-mode' is enabled."
(when (and (featurep 'recentf)
recentf-mode
(fboundp 'recentf-cleanup))
(recentf-cleanup)))
(add-hook 'kill-emacs-hook #'minimal-emacs--cleanup-hook)
(setq recentf-auto-cleanup (if (daemonp) 300 'mode))
;; Update recentf-exclude
(setq recentf-exclude (list "^/\\(?:ssh\\|su\\|sudo\\)?:"))