From 296c4d7c09cf66b2a97e8871c5a903fda9d0919e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 28 Oct 2022 19:43:06 -0500 Subject: uhhhhh --- lisp/+custom.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lisp/+custom.el (limited to 'lisp/+custom.el') diff --git a/lisp/+custom.el b/lisp/+custom.el new file mode 100644 index 0000000..ba4c55d --- /dev/null +++ b/lisp/+custom.el @@ -0,0 +1,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 -- cgit 1.4.1-21-gabe81