-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathEldev
166 lines (122 loc) · 5.29 KB
/
Eldev
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
; -*- mode: emacs-lisp; lexical-binding: t; no-byte-compile: t -*-
;; Inject private configurations
(let ((private-dir (getenv "EMACS_PRIVATE_DIR")))
(when (and private-dir (file-exists-p private-dir))
(let ((files (seq-filter
(lambda (file)
(and (string-suffix-p ".el" file)
(not (string-match ".*#.*" file))
(not (string-prefix-p "flycheck_" file))))
(directory-files private-dir nil "^\\([^.]\\|\\.[^.]\\|\\.\\..\\)"))))
(mapc
(lambda (file)
(shell-command-to-string
(format
"safe_link %s%s %s/lisp/%s" private-dir file eldev-project-dir file)))
files))))
;; Be explicit about main file.
(setf eldev-project-main-file "init.el"
eldev-main-fileset '(:and ("init.el"
"early-init.el"
"lisp/*.el")
(:not ("**/flycheck_*.el"))))
;; Emacs doesn't allow to add directory containing init.el to load
;; path, so we have to put other Emacs Lisp files in directory. Help
;; Eldev commands to locate them.
(eldev-add-loading-roots 'build "lisp")
(eldev-add-loading-roots 'bootstrap "lisp")
(eldev-add-loading-roots 'test "lisp")
;; There are dependencies for testing and linting phases, they should
;; be installed by Eldev from MELPA and GNU ELPA (latter is enabled by
;; default).
(eldev-use-package-archive 'melpa)
;; Bootstrap flow. Basically set `elpa-bootstrap-p' to `t' and load
;; init.el, which forces `init-elpa' to install all dependencies.
(defun elpa-bootstrap ()
"Bootstrap personal configurations."
(setq-default
elpa-bootstrap-p t
load-prefer-newer t)
(eldev--inject-loading-roots 'bootstrap)
(require 'config-path)
(load (expand-file-name "init.el" path-emacs-dir))
(elpaca-wait))
;; We want to run this before any build command. This is also needed
;; for `flyspell-eldev` to be aware of packages installed by
;; elpaca/straight/whatever.
(add-hook 'eldev-build-system-hook #'elpa-bootstrap)
;; Upgrade flow. Hooks into Eldev upgrade flow.
(defun elpa-upgrade ()
"Bootstrap personal configurations."
(elpa-bootstrap))
(add-hook 'eldev-upgrade-hook #'elpa-upgrade)
(add-hook 'eldev-test-hook #'elpa-bootstrap)
(defun -vulpea-db-bootstrap ()
"Bootstrap `vulpea-db'."
(run-hooks 'after-init-hook)
(vulpea-db-build))
(defun -brb-sync ()
"Sync brb data."
(run-hooks 'after-init-hook)
(brb-sync-external-data-with-upstream))
(defun elpa-load-autoloads-file ()
(eldev--load-autoloads-file
(expand-file-name "lisp/init-autoloads.el" eldev-project-dir)))
;; Always load autoloads file.
(add-hook 'eldev-build-system-hook #'elpa-load-autoloads-file)
(add-hook 'eldev-test-hook #'elpa-load-autoloads-file)
;; Linting configurations.
;; Tell checkdoc not to demand two spaces after a period.
(setq sentence-end-double-space nil)
(defun eldev-lint-find-files-absolute (f &rest args)
"Call F with ARGS and ensure that result is absolute paths."
(seq-map (lambda (p)
(expand-file-name p eldev-project-dir))
(seq-filter (lambda (p)
(not (string-suffix-p "autoloads.el" p)))
(apply f args))))
(advice-add 'eldev-lint-find-files :around #'eldev-lint-find-files-absolute)
;; In general, `package-lint' is useful. But package prefix naming
;; policy is not useful for personal configurations. So we chop
;; lib/init part from the package name.
;;
;; And `eval-after-load'. In general it's not a good idea to use it in
;; packages, but these are configurations.
(with-eval-after-load 'package-lint
(defun package-lint--package-prefix-cleanup (prefix)
"Cleanup PREFIX."
(replace-regexp-in-string
"\\(private\\)-?" ""
(replace-regexp-in-string
"\\(init\\|lib\\|config\\|compat\\)-?" ""
prefix)))
(defun package-lint--get-package-prefix-wrapper (f &rest args)
"Call F with ARGS and cleanup it's result."
(let ((r (apply f args)))
(package-lint--package-prefix-cleanup r)))
(advice-add 'package-lint--get-package-prefix :around #'package-lint--get-package-prefix-wrapper)
(defun package-lint--check-defs-prefix-wrapper (f prefix definitions)
"Call F with cleared PREFIX and DEFINITIONS."
(funcall f (package-lint--package-prefix-cleanup prefix) definitions))
(advice-add 'package-lint--check-defs-prefix :around #'package-lint--check-defs-prefix-wrapper)
(defun package-lint--check-defalias-wrapper (f prefix def)
"Call F with cleared PREFIX and DEF."
(funcall f (package-lint--package-prefix-cleanup prefix) def))
(advice-add 'package-lint--check-defalias :around #'package-lint--check-defalias-wrapper)
(defun package-lint--check-eval-after-load ()
"Do nothing.")
(defun package-lint--check-autoloads-on-private-functions (&rest _)
"Do nothing.")
(defun package-lint--check-emacs-version (_)
"Do nothing"))
;; Teach linter how to properly indent emacsql vectors.
(eldev-add-extra-dependencies 'lint 'emacsql)
(add-hook 'eldev-lint-hook
(lambda ()
(eldev-load-project-dependencies 'lint nil t)
(require 'emacsql)
(call-interactively #'emacsql-fix-vector-indentation)))
;; CI compat
(when (getenv "CI")
(defun font-info (name &optional frame)
"Do nothing."))