;;; +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