Emacs: Tidy up package-management.el.

Remove my/straight-update-repos, simplify my/straight-check-last-update,
wrap straight-related functions and hooks in use-package recipe.
This commit is contained in:
tastytea 2020-11-10 22:30:12 +01:00
parent 50e1f5bb49
commit 02a0a184a1
1 changed files with 16 additions and 24 deletions

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-07-04T15:45:08+0200> ;; Time-stamp: <2020-11-10T22:28:36+0100>
;;; Commentary: ;;; Commentary:
;; * Set up straight ;; * Set up straight
@ -42,34 +42,26 @@
(goto-char (point-max)) (goto-char (point-max))
(eval-print-last-sexp))) (eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)) (load bootstrap-file nil 'nomessage))
(require 'straight)
(require 'straight) ; Shut up flycheck.
(add-hook 'after-init-hook #'straight-prune-build) ; Remove unnused packages.
;; Isolate package configurations. ;; Isolate package configurations.
(straight-use-package 'use-package) (straight-use-package 'use-package)
(customize-set-variable 'use-package-always-defer t) (customize-set-variable 'use-package-always-defer t)
(require 'use-package)
(defun my/straight-check-last-update () (use-package straight
"Update recipe repositories after 7 days have passed since the last package was built." :config (defun my/straight-check-last-update ()
(let ((days 7) "Update recipe repositories after 7 days have passed since the last package was built."
(mtime-seconds (time-to-seconds (let ((days 7)
(file-attribute-modification-time (mtime-seconds (time-to-seconds
(file-attributes (straight--build-dir)))))) (file-attribute-modification-time
(when (> (- (time-to-seconds) mtime-seconds) (file-attributes (straight--build-dir))))))
(* 60 60 24 days)) (when (> (- (time-to-seconds) mtime-seconds)
(dolist (package ; straight-recipe-repositories (* 60 60 24 days))
'("org-elpa" "melpa" "gnu-elpa-mirror" "emacsmirror-mirror")) (dolist (package straight-recipe-repositories)
(straight-pull-package package))))) (straight-pull-package package)))))
(add-hook 'emacs-startup-hook #'my/straight-check-last-update) :hook ((emacs-startup . my/straight-check-last-update)
((after-init . straight-prune-build))))
(defun my/straight-update-repos ()
"Update MELPA, ELPA and Emacsmirror."
(interactive)
(straight-pull-package 'melpa)
(straight-pull-package 'gnu-elpa-mirror)
(straight-pull-package 'emacsmirror-mirror))
(provide 'basics/package-management) (provide 'basics/package-management)
;;; package-management.el ends here ;;; package-management.el ends here