From f4dc5002d94fc2ebcab96a6058f1294cbff674bb Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Tue, 30 Jul 2024 16:40:09 +0200 Subject: [PATCH] Manage crafted-emacs repository --- early-init.el | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/early-init.el b/early-init.el index d6ea60f..5e54a24 100644 --- a/early-init.el +++ b/early-init.el @@ -47,6 +47,19 @@ ;; Wait for elpaca (elpaca-wait) +(setq crafted-emacs-home "~/.local/share/crafted-emacs") + +(defun check-crafted-emacs-fresh-repo () + "Check if the crafted-emacs repo is fresh." + (if (file-exists-p crafted-emacs-home) + (progn + (message "Crafted Emacs repo exists. Pulling...") + (shell-command (format "cd %s && git pull" crafted-emacs-home))) + (progn + (message "Crafted Emacs repo does not exist. Cloning...") + (shell-command (format "git clone https://github.com/SystemCrafters/crafted-emacs.git %s" crafted-emacs-home))) + )) + ;; tangling to generate scripts for the local bin directory. This ;; causes the name of the scripts to be returned in the car of the ;; tangle command which is used to load the file. The net result is @@ -58,8 +71,12 @@ (if (file-newer-than-file-p src tgt) (progn (message "snamellit.org has been changed, tangling...") - (org-babel-tangle-file src tgt "emacs-lisp")))) - + (org-babel-tangle-file src tgt "emacs-lisp") + ;; this is a good time to check if the crafted-emacs repo is fresh + ;; - we just updated the init.org file so we expect changes. + ;; - or this is the initial tangling and we need the repo to exist. + (check-crafted-emacs-fresh-repo) + ))) ;; Configure Crafted Emacs (setq crafted-package-system 'elpaca) @@ -68,7 +85,6 @@ ;; Startup Crafted Emacs -(setq crafted-emacs-home "~/.local/share/crafted-emacs") (load (expand-file-name "modules/crafted-package-config" crafted-emacs-home)) (load (expand-file-name "modules/crafted-early-init-config" crafted-emacs-home))