forked from tgbugs/orgstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-simple.el
97 lines (81 loc) · 4.46 KB
/
init-simple.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;;;; init-simple.el --- entry point -*- lexical-binding: t -*-
;; Author: Tom Gillespie
;; Homepage: https://github.com/tgbugs/orgstrap
;; Version: 9999
;; Package-Requires: ((emacs "24.4"))
;; Is-Version-Of: https://raw.githubusercontent.com/tgbugs/orgstrap/master/init-simple.el
;;;; License and Commentary
;; License:
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; init-simple.el should be copied into to ~/.emacs.d/init.el on
;; systems that need access to a minimally configured emacs that has
;; the key packages loaded that we need for productively working on
;; random systems. init-simple.el acts as a stub that points to a
;; remote init-content.el file which is what is kept up to date and
;; can be synchronized across multiple deployments. Since we use reval
;; to do this init-simple.el will only update if `reval-update' is
;; invoked explicitly. For this reason we do not include the machinery
;; for updating init-simple.el itself using reval. At some point I
;; will get caching implemented as part of reval, at which point we
;; will only have to go to network once per update.
;;; Code:
;; user config dir when testing
(defvar init-simple-testing nil)
(when init-simple-testing
(defconst working-dir
(concat (file-name-directory (or load-file-name (buffer-file-name)))
"emacs-d-testing/" (number-to-string emacs-major-version) "/")
"Directory where this file is located")
(defvar init-simple-user-dir (expand-file-name "init-simple-user" working-dir))
(setq user-emacs-directory init-simple-user-dir)
(defcustom init-simple-use-default-package-dir nil
"By default do not use default package dir.")
(unless init-simple-use-default-package-dir
(setq package-user-dir (expand-file-name
; emacs 28 introduces a bunch if incompatible changes
(concat "init-simple-elpa-" emacs-version)
working-dir))))
;;; load remote code
(unless (featurep 'reval)
(defvar reval-cache-directory (concat user-emacs-directory "reval/cache/"))
(defun reval-minimal (cypher checksum path-or-url &rest alternates)
"Simplified and compact implementation of reval."
(let* (done (o url-handler-mode) (csn (symbol-name checksum))
(cache-path (concat reval-cache-directory (substring csn 0 2) "/" csn
"-" (file-name-nondirectory path-or-url))))
(url-handler-mode)
(unwind-protect
(cl-loop for path-or-url in (cons cache-path (cons path-or-url alternates))
do (when (file-exists-p path-or-url)
(let* ((buffer (find-file-noselect path-or-url))
(buffer-checksum (intern (secure-hash cypher buffer))))
(if (eq buffer-checksum checksum)
(progn
(unless (string= path-or-url cache-path)
(let ((parent-path (file-name-directory cache-path))
make-backup-files)
(unless (file-directory-p parent-path)
(make-directory parent-path t))
(with-current-buffer buffer
(write-file cache-path))))
(eval-buffer buffer)
(setq done t))
(kill-buffer buffer) ; kill so cannot accidentally evaled
(error "reval: checksum mismatch! %s" path-or-url))))
until done)
(unless o
(url-handler-mode 0)))))
(defalias 'reval #'reval-minimal)
(reval 'sha256 '3620321396c967395913ff19ce507555acb92335b0545e4bd05ec0e673a0b33b
"https://raw.githubusercontent.com/tgbugs/orgstrap/300b1d5518af53d76d950097bcbcd7046cfa2285/reval.el"))
(let ((ghost "https://raw.githubusercontent.com/tgbugs/orgstrap/"))
;; FIXME ghost breaks the reval helper code
(unless (featurep 'ow)
(reval 'sha256 'a3f04d3c136a69f92b220a79bb1074e7f7294b057438f10abe31f151f751f37c
;; "~/git/orgstrap/ow.el"
(concat ghost "75a18955a97b1da2754bf43da6b26e22ec07dc52" "/ow.el")))
(reval 'sha256 'e6dce9d3e7861b4650f228a3b2835ece989e738921abad9f2a4ac3dcd93e2854
;; "~/git/orgstrap/init-content.el"
(concat ghost "460030279c3553e67bd84872dd029d75368346a8" "/init-content.el")))
;;;; init-simple.el ends here