Emacs: Add my/straight-update-repos.

This commit is contained in:
tastytea 2020-11-18 18:10:59 +01:00
parent c2175d42af
commit bf54968d65
1 changed files with 17 additions and 11 deletions

View File

@ -1,6 +1,6 @@
;;; 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:
;; * Set up straight
@ -50,16 +50,22 @@
(require 'use-package)
(use-package straight
:config (defun my/straight-check-last-update ()
"Update recipe repositories after 7 days have passed since the last package was built."
(let ((days 7)
(mtime-seconds (time-to-seconds
(file-attribute-modification-time
(file-attributes (straight--build-dir))))))
(when (> (- (time-to-seconds) mtime-seconds)
(* 60 60 24 days))
(dolist (package straight-recipe-repositories)
(straight-pull-package package)))))
: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."
(let ((days 7)
(mtime-seconds (time-to-seconds
(file-attribute-modification-time
(file-attributes (straight--build-dir))))))
(when (> (- (time-to-seconds) mtime-seconds)
(* 60 60 24 days))
(my/straight-update-repos)))))
:hook ((emacs-startup . my/straight-check-last-update)
((after-init . straight-prune-build))))