Emacs: Only update repositories if newest MELPA recipe is old.
This commit is contained in:
parent
7660013ead
commit
6795bd2d77
|
@ -1,6 +1,6 @@
|
|||
;;; package-management.el --- Initialize package management -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-26T16:12:08+0100>
|
||||
;; Time-stamp: <2020-03-27T00:26:50+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Set up straight
|
||||
|
@ -49,15 +49,23 @@
|
|||
(defun my/straight-check-last-update ()
|
||||
"Notify if 7 days have passed since the last package was built."
|
||||
(let ((days 7))
|
||||
(when (> (- (time-to-seconds)
|
||||
(time-to-seconds (file-attribute-modification-time
|
||||
(file-attributes (straight--build-dir)))))
|
||||
(* 60 60 24 days))
|
||||
;; Refresh repositories.
|
||||
(straight-pull-package 'melpa)
|
||||
(straight-pull-package 'gnu-elpa-mirror)
|
||||
(straight-pull-package 'emacsmirror-mirror)
|
||||
(message "The last package update was more than %d days ago." days))))
|
||||
(cl-flet ((file-old?
|
||||
(lambda (file)
|
||||
"Return t if FILE was modified more than DAYS ago."
|
||||
(if (> (- (time-to-seconds)
|
||||
(time-to-seconds (file-attribute-modification-time
|
||||
(file-attributes file))))
|
||||
(* 60 60 24 days))
|
||||
t
|
||||
nil))))
|
||||
(when (file-old? (straight--build-dir))
|
||||
;; Update repositories if newest MELPA recipe is older than DAYS.
|
||||
(when (file-old?
|
||||
(expand-file-name "melpa/recipes" (straight--repos-dir)))
|
||||
(straight-pull-package 'melpa)
|
||||
(straight-pull-package 'gnu-elpa-mirror)
|
||||
(straight-pull-package 'emacsmirror-mirror))
|
||||
(message "The last package update was more than %d days ago." days)))))
|
||||
(add-hook 'emacs-startup-hook #'my/straight-check-last-update)
|
||||
|
||||
;; ;; Autocompile files on load.
|
||||
|
|
Loading…
Reference in New Issue