-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinit-simple.el
112 lines (94 loc) · 5.17 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
;;;; 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.
;;; 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
;; emacs tries to be smart about coding systems for things loaded
;; via url handler mode, and/or github decided to try to be smart
;; and modify the contents of the blob they send based on which os
;; they detect, either way, this breaks reval completely, so we set
;; `prefer-coding-system' to avoid the issue
(prefer-coding-system 'utf-8-unix)
(when (< emacs-major-version 26)
;; apparently org switched to the function form at some point
(defun temporary-file-directory () temporary-file-directory)
;; we used to be able to set this in ow.el and everything would
;; succeed, but it seems that at some point something change and
;; the 25 now waits infinitely trying to connect to github so we
;; never get to ow.el where this is also set, for some reason 24
;; does not have this issue
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
(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 '670c68e5649987fb64a93a7b5610ace0f18a0b71f376faf7499de933247931f2
;;"~/git/orgstrap/ow.el"
(concat ghost "021b66c8f1dd4bf55714a4de889f31741f8460f6" "/ow.el")))
(reval 'sha256 'f4c237e4fa1e045ec68a285bcd97cbf3c065436974dd6e5396ece395ba63ea5e
;; "~/git/orgstrap/init-content.el"
(concat ghost "5f930d8467447e067914eb3aacbd36623982607c" "/init-content.el")))
;;;; init-simple.el ends here