diff --git a/init.d/basics/package-management.el b/init.d/basics/package-management.el index 24c315b..b63b239 100644 --- a/init.d/basics/package-management.el +++ b/init.d/basics/package-management.el @@ -1,6 +1,6 @@ ;;; package-management.el --- Initialize package management. -*- lexical-binding: t; -*- -;; Time-stamp: <2020-02-24T22:03:02+0100> +;; Time-stamp: <2020-02-26T23:05:38+0100> ;;; Commentary: ;; * Sets up package sources and their priorities. @@ -10,6 +10,8 @@ ;;; Code: +(require 'basics/global-variables) + (require 'package) (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) @@ -79,10 +81,25 @@ ;; Install Emacs packages directly from source. (use-package quelpa - :custom ((quelpa-upgrade-p t) - (quelpa-self-upgrade-p nil) + :demand t + :custom ((quelpa-self-upgrade-p nil) (quelpa-update-melpa-p nil) (quelpa-checkout-melpa-p nil)) + :config + (defvar my/quelpa-last-upgrade-file + (concat user-emacs-directory "quelpa/last_upgrade") + "File with the timestamp of the last quelpa upgrade.") + + (defun my/quelpa-maybe-upgrade () + "Upgrade quelpa packages if the last upgrade was > 7 days ago." + (when (or (not (file-exists-p my/quelpa-last-upgrade-file)) + (> (- (time-to-seconds) + (my/file-last-modification my/quelpa-last-upgrade-file)) + (* 60 60 24 7))) + (quelpa-upgrade-all) + (write-region "" nil my/quelpa-last-upgrade-file))) + + :hook (after-init . my/quelpa-maybe-upgrade) ) (provide 'basics/package-management)