Emacs: Refactor package-management.el.
Update commentary, move GNUTLS to the top, notification if last update was 7+ days ago, remove gnu-elpa-keyring-update.
This commit is contained in:
parent
216003eff9
commit
e7eab3ae69
|
@ -1,26 +1,30 @@
|
|||
;;; package-management.el --- Initialize package management. -*- lexical-binding: t; -*-
|
||||
;;; package-management.el --- Initialize package management -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-16T00:13:48+0100>
|
||||
;; Time-stamp: <2020-03-16T01:12:54+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Set up package sources and their priorities.
|
||||
;; * Set up straight
|
||||
;; * Set up use-package.
|
||||
;; * Compile elisp files.
|
||||
;; * Update keyring.
|
||||
;; * Update packages.
|
||||
;; * Set up quelpa.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Workaround for < 26.3 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341>.
|
||||
(when (and (< emacs-major-version 27)
|
||||
(not (string= emacs-version "26.3")))
|
||||
(defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
||||
|
||||
;; Define variables for straight.
|
||||
(customize-set-variable
|
||||
'straight-use-package-by-default t
|
||||
"Makes use-package invoke straight.el to install the package.")
|
||||
(customize-set-variable 'straight-cache-autoloads t
|
||||
"Cache the autoloads of all packages in a single file.")
|
||||
|
||||
;; Bootstrap straight.
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
|
||||
(expand-file-name "straight/repos/straight.el/bootstrap.el"
|
||||
user-emacs-directory))
|
||||
(bootstrap-version 5))
|
||||
(unless (file-exists-p bootstrap-file)
|
||||
(with-current-buffer
|
||||
|
@ -31,43 +35,31 @@
|
|||
(eval-print-last-sexp)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
|
||||
(add-hook 'after-init-hook #'straight-prune-build)
|
||||
(require 'straight) ; Shut up flycheck.
|
||||
|
||||
;; Workaround for 26.2 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341>.
|
||||
(when (< emacs-major-version 27)
|
||||
(defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
||||
(add-hook 'after-init-hook #'straight-prune-build) ; Remove unnused packages.
|
||||
|
||||
;; Isolate package configurations.
|
||||
(straight-use-package 'use-package)
|
||||
|
||||
(defun my/straight-pull-all-maybe ()
|
||||
"Run `straight-pull-all' if 7 days have passed since the build cache was modified."
|
||||
(defun my/straight-check-last-update ()
|
||||
"Notify if 7 days have passed since the build cache was modified."
|
||||
(unless straight-cache-autoloads
|
||||
(error "`straight-cache-autoloads' needs to be t"))
|
||||
(let ((days 7))
|
||||
(if (> (- (time-to-seconds)
|
||||
(time-to-seconds
|
||||
(file-attribute-modification-time
|
||||
(file-attributes (expand-file-name "straight/build-cache.el"
|
||||
user-emacs-directory)))))
|
||||
(* 60 60 24 days))
|
||||
(straight-pull-all))))
|
||||
(when (> (- (time-to-seconds)
|
||||
(time-to-seconds
|
||||
(file-attribute-modification-time
|
||||
(file-attributes (expand-file-name "straight/build-cache.el"
|
||||
user-emacs-directory)))))
|
||||
(* 60 60 24 days))
|
||||
(message "The last update was more than %d days ago." days))))
|
||||
(add-hook 'after-init-hook #'my/straight-check-last-update)
|
||||
|
||||
;; ;; Autocompile files on load.
|
||||
;; (use-package auto-compile
|
||||
;; :custom (load-prefer-newer t) ; Use uncompiled file if it is newer.
|
||||
;; :config (auto-compile-on-load-mode))
|
||||
|
||||
;; Tool for updating the GNU ELPA keyring.
|
||||
(use-package gnu-elpa-keyring-update
|
||||
:config
|
||||
(defvar my/keyring-last-access
|
||||
(time-to-seconds
|
||||
(file-attribute-access-time
|
||||
(file-attributes gnu-elpa-keyring-update--keyring)))
|
||||
"Last access time for the GNU ELPA keyring.")
|
||||
|
||||
;; Only update keyring if atime (mtime with relatime) is > 1 week ago.
|
||||
(if (> (- (time-to-seconds) my/keyring-last-access) (* 60 60 24 7))
|
||||
(gnu-elpa-keyring-update)))
|
||||
|
||||
(provide 'basics/package-management)
|
||||
;;; package-management.el ends here
|
||||
|
|
Loading…
Reference in New Issue
Block a user