perf(rss): defer db compaction

Compacting elfeed's DB when killing the search buffer can incur a long
delay (which blocks Emacs). Doing so isn't really critical, so I've
moved it to kill-emacs-hook instead.

Close: #7127
Co-authored-by: merrickluo <merrickluo@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2023-03-11 13:03:20 -05:00
parent adb125f41f
commit f1f010ff99
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -81,14 +81,18 @@
(setq-local shr-width 85) (setq-local shr-width 85)
(set-buffer-modified-p nil))) (set-buffer-modified-p nil)))
(defun +rss--cleanup-on-kill-h ()
"Run `elfeed-db-compact'. See `+rss-cleanup-h'."
;; `delete-file-projectile-remove-from-cache' slows down `elfeed-db-compact'
;; tremendously, so we disable the projectile cache:
(let (projectile-enable-caching)
(elfeed-db-compact)))
;;;###autoload ;;;###autoload
(defun +rss-cleanup-h () (defun +rss-cleanup-h ()
"Clean up after an elfeed session. Kills all elfeed and elfeed-org files." "Clean up after an elfeed session. Kills all elfeed and elfeed-org files."
(interactive) (interactive)
;; `delete-file-projectile-remove-from-cache' slows down `elfeed-db-compact' (add-hook 'kill-emacs-hook #'+rss--cleanup-on-kill-h)
;; tremendously, so we disable the projectile cache:
(let (projectile-enable-caching)
(elfeed-db-compact))
(let ((buf (previous-buffer))) (let ((buf (previous-buffer)))
(when (or (null buf) (not (doom-real-buffer-p buf))) (when (or (null buf) (not (doom-real-buffer-p buf)))
(switch-to-buffer (doom-fallback-buffer)))) (switch-to-buffer (doom-fallback-buffer))))