aboutsummaryrefslogtreecommitdiff
path: root/modules/local-repository.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/local-repository.el')
-rw-r--r--modules/local-repository.el35
1 files changed, 25 insertions, 10 deletions
diff --git a/modules/local-repository.el b/modules/local-repository.el
index b97b74f41..e3c7a227a 100644
--- a/modules/local-repository.el
+++ b/modules/local-repository.el
@@ -1,4 +1,4 @@
-;;; local-repository.el --- local repository functionality -*- lexical-binding: t; coding: utf-8; -*-
+;;; local-repository.el --- Local package archive helpers -*- lexical-binding: t; coding: utf-8; -*-
;; author Craig Jennings <c@cjennings.net>
;;; Commentary:
@@ -6,42 +6,57 @@
;; Layer: 4 (Optional).
;; Category: O/D/P.
;; Load shape: eager.
-;; Eager reason: none; local package-mirror workflow, a command-loaded deferral
-;; candidate.
+;; Eager reason: none; local package mirror commands can autoload.
;; Top-level side effects: none.
-;; Runtime requires: elpa-mirror.
+;; Runtime requires: elpa-mirror when updating the mirror.
;; Direct test load: yes.
;;
+;; Adds the checked-in local package archive to package-archives with high
+;; priority, and provides a command to refresh that archive from installed
+;; packages via elpa-mirror.
+
;;; Code:
(require 'elpa-mirror nil t) ;; optional; cj/update-localrepo-repository fails at call-time if absent
+(declare-function elpamr-create-mirror-for-installed "elpa-mirror")
+
;; ------------------------------ Utility Function -----------------------------
-(defun car-member (value list)
+(defun localrepo--car-member (value list)
"Check if VALUE exists as the car of any cons cell in LIST."
(member value (mapcar #'car list)))
;; ------------------------------- Customizations ------------------------------
+(defgroup localrepo nil
+ "Local last-known-good package repository."
+ :group 'package)
+
(defcustom localrepo-repository-id "localrepo"
"The name used to identify the local repository internally.
-Used for the package-archive and package-archive-priorities lists.")
+Used for the package-archive and package-archive-priorities lists."
+ :type 'string
+ :group 'localrepo)
(defcustom localrepo-repository-priority 100
"The value for the local repository in the package-archive-priority list.
A higher value means higher priority. If you want your local packages to be
-preferred, this must be a higher number than any other repositories.")
+preferred, this must be a higher number than any other repositories."
+ :type 'integer
+ :group 'localrepo)
(defcustom localrepo-repository-location
(concat user-emacs-directory "/.localrepo")
"The location of the local repository.
It's a good idea to keep this with the rest of your configuration files and
-keep them in source control.")
+keep them in source control."
+ :type 'directory
+ :group 'localrepo)
(defun cj/update-localrepo-repository ()
"Update the local repository with currently installed packages."
@@ -50,11 +65,11 @@ keep them in source control.")
(defun localrepo-initialize ()
"Add the repository to the package archives, then gives it a high priority."
- (unless (car-member localrepo-repository-id package-archives)
+ (unless (localrepo--car-member localrepo-repository-id package-archives)
(add-to-list 'package-archives
(cons localrepo-repository-id localrepo-repository-location)))
- (unless (car-member localrepo-repository-id package-archive-priorities)
+ (unless (localrepo--car-member localrepo-repository-id package-archive-priorities)
(add-to-list 'package-archive-priorities
(cons localrepo-repository-id localrepo-repository-priority))))