blob: ba4c55d1575220371ba19a206358d047a1cf276b (
plain)
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
|
;;; +custom.el -*- lexical-binding: t -*-
(require 'cl-lib)
(require 'seq)
(defgroup +custom nil
"Group for extra `customize' customizations."
:group 'customize)
(defcustom +custom-allowed-variables nil
"Variables to load during `+custom-load-some-customizations'."
:type '(repeat symbol))
(defcustom +custom-allowed-faces nil
"Faces to load during `+custom-load-some-customziations'."
:type '(repeat face))
(defun +custom--filter-list (customlist allowlist)
"Filter CUSTOMLIST to only include those items in ALLOWLIST.
Each item in ALLOWLIST will be compared using `eq' to the `car'
of each item in CUSTOMLIST. Items in CUSTOMLIST not included in
ALLOWLIST will be removed from the return value."
(seq-filter (lambda (el) (memq (car el) allowlist))
customlist))
(defcustom +custom-after-load-hook nil
"Hook run after loading the custom file."
:type 'hook)
(defun +custom-load-some-customizations (&optional noerror
nomessage
nosuffix
must-suffix)
"Load `custom-file', ignoring most customizations.
Only faces included in `+custom-allowed-faces' and variables
included in `+custom-allowed-variables' will be loaded.
All optional arguments---NOERROR, NOMESSAGE, NOSUFFIX,
MUST-SUFFIX---are passed to `load', which see."
(cl-letf (((symbol-function 'custom-set-faces)
(lambda (&rest args)
(apply #'custom-theme-set-faces 'user
(+custom--filter-list args +custom-allowed-faces))))
((symbol-function 'custom-set-variables)
(lambda (&rest args)
(apply #'custom-theme-set-variables 'user
(+custom--filter-list args +custom-allowed-variables)))))
(load custom-file noerror nomessage nosuffix must-suffix))
(run-hooks '+custom-after-load-hook))
(provide '+custom)
;;; +custom.el ends here
|