Emacs: Add my/straight-update-repos.

This commit is contained in:
tastytea 2020-11-18 18:10:59 +01:00
parent c2175d42af
commit bf54968d65

View File

@ -1,6 +1,6 @@
;;; package-management.el --- Initialize package management -*- lexical-binding: t; -*- ;;; package-management.el --- Initialize package management -*- lexical-binding: t; -*-
;; Time-stamp: <2020-11-10T22:28:36+0100> ;; Time-stamp: <2020-11-18T18:09:44+0100>
;;; Commentary: ;;; Commentary:
;; * Set up straight ;; * Set up straight
@ -50,7 +50,14 @@
(require 'use-package) (require 'use-package)
(use-package straight (use-package straight
:config (defun my/straight-check-last-update () :config (progn
(defun my/straight-update-repos ()
"Update recipe repositories."
(interactive)
(dolist (package straight-recipe-repositories)
(straight-pull-package package)))
(defun my/straight-check-last-update ()
"Update recipe repositories after 7 days have passed since the last package was built." "Update recipe repositories after 7 days have passed since the last package was built."
(let ((days 7) (let ((days 7)
(mtime-seconds (time-to-seconds (mtime-seconds (time-to-seconds
@ -58,8 +65,7 @@
(file-attributes (straight--build-dir)))))) (file-attributes (straight--build-dir))))))
(when (> (- (time-to-seconds) mtime-seconds) (when (> (- (time-to-seconds) mtime-seconds)
(* 60 60 24 days)) (* 60 60 24 days))
(dolist (package straight-recipe-repositories) (my/straight-update-repos)))))
(straight-pull-package package)))))
:hook ((emacs-startup . my/straight-check-last-update) :hook ((emacs-startup . my/straight-check-last-update)
((after-init . straight-prune-build)))) ((after-init . straight-prune-build))))