From afdc6a31b52e6ead448c796e37fc63870b9ca7b2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 13 May 2018 17:27:38 +0200 Subject: [PATCH] Move def-setting! macros to core-packages --- core/core-lib.el | 38 -------------------------------------- core/core-packages.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 9d68fa636..305aeeb13 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -229,43 +229,5 @@ Body forms can access the hook's arguments through the let-bound variable (t (user-error "associate! invalid rules for mode [%s] (modes %s) (match %s) (files %s)" mode modes match files)))))) - -;; I needed a way to reliably cross-configure modules without worrying about -;; whether they were enabled or not, so I wrote `set!'. If a setting doesn't -;; exist at runtime, the `set!' call is ignored and its arguments are left -;; unevaluated (and entirely omitted when byte-compiled). -(defvar doom-settings nil) - -(defmacro def-setting! (keyword arglist &optional docstring &rest forms) - "Define a setting. Like `defmacro', this should return a form to be executed -when called with `set!'. FORMS are not evaluated until `set!' calls it. - -See `doom/describe-setting' for a list of available settings. - -Do not use this for configuring Doom core." - (declare (indent defun) (doc-string 3)) - (unless (keywordp keyword) - (error "Not a valid property name: %s" keyword)) - (let ((fn (intern (format "doom--set%s" keyword)))) - `(progn - (defun ,fn ,arglist - ,docstring - ,@forms) - (cl-pushnew ',(cons keyword fn) doom-settings :test #'eq :key #'car)))) - -(defmacro set! (keyword &rest values) - "Set an option defined by `def-setting!'. Skip if doesn't exist. See -`doom/describe-setting' for a list of available settings. - -VALUES doesn't get evaluated if the KEYWORD setting doesn't exist." - (declare (indent defun)) - (unless values - (error "Empty set! for %s" keyword)) - (if-let* ((fn (cdr (assq keyword doom-settings)))) - (apply fn values) - (when doom-debug-mode - (message "No setting found for %s" keyword) - nil))) - (provide 'core-lib) ;;; core-lib.el ends here diff --git a/core/core-packages.el b/core/core-packages.el index 214e68a49..c675c18b3 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -932,5 +932,47 @@ compiled packages.'" (advice-add #'package-autoremove :override #'doom//packages-autoremove) (advice-add #'package-install-selected-packages :override #'doom//packages-install) + +;; +;; Cross-module configuration +;; + +;; I needed a way to reliably cross-configure modules without worrying about +;; whether they were enabled or not, so I wrote `set!'. If a setting doesn't +;; exist at runtime, the `set!' call is ignored and its arguments are left +;; unevaluated (and entirely omitted when byte-compiled). +(defvar doom-settings nil) + +(defmacro def-setting! (keyword arglist &optional docstring &rest forms) + "Define a setting. Like `defmacro', this should return a form to be executed +when called with `set!'. FORMS are not evaluated until `set!' calls it. + +See `doom/describe-setting' for a list of available settings. + +Do not use this for configuring Doom core." + (declare (indent defun) (doc-string 3)) + (unless (keywordp keyword) + (error "Not a valid property name: %s" keyword)) + (let ((fn (intern (format "doom--set%s" keyword)))) + `(progn + (defun ,fn ,arglist + ,docstring + ,@forms) + (cl-pushnew ',(cons keyword fn) doom-settings :test #'eq :key #'car)))) + +(defmacro set! (keyword &rest values) + "Set an option defined by `def-setting!'. Skip if doesn't exist. See +`doom/describe-setting' for a list of available settings. + +VALUES doesn't get evaluated if the KEYWORD setting doesn't exist." + (declare (indent defun)) + (unless values + (error "Empty set! for %s" keyword)) + (if-let* ((fn (cdr (assq keyword doom-settings)))) + (apply fn values) + (when doom-debug-mode + (message "No setting found for %s" keyword) + nil))) + (provide 'core-packages) ;;; core-packages.el ends here