Move core/autoload/set.el into core/core-lib.el
This commit is contained in:
parent
fe4429fa40
commit
a511d5ea00
2 changed files with 30 additions and 40 deletions
|
@ -1,40 +0,0 @@
|
||||||
;;; set.el
|
|
||||||
(provide 'doom-lib-set)
|
|
||||||
|
|
||||||
;; This provides a centralized configuration system that a) won't evaluate its
|
|
||||||
;; arguments if it doesn't need to (performance), b) won't complain if the
|
|
||||||
;; setting doesn't exist and c) is more elegant than a bunch of `@after' blocks,
|
|
||||||
;; which can cause intermittent stuttering in large quantities. I'm a fan of
|
|
||||||
;; concise, do-what-I-mean front-facing configuration, believe it or not.
|
|
||||||
;;
|
|
||||||
;; Plus, it can benefit from byte-compilation.
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defmacro @def-setting (keyword arglist &optional docstring &rest forms)
|
|
||||||
"Define a setting macro. Like `defmacro', this should return a form to be
|
|
||||||
executed when called with `@set'. FORMS are not evaluated until `@set' calls it."
|
|
||||||
(declare (indent defun) (doc-string 3))
|
|
||||||
(unless (keywordp keyword)
|
|
||||||
(error "Not a valid property name: %s" keyword))
|
|
||||||
`(defun ,(intern (format "doom-setting--setter%s" keyword)) ,arglist
|
|
||||||
,docstring
|
|
||||||
,@forms))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defmacro @set (keyword &rest values)
|
|
||||||
"Set an option defined by `@def-setting'. Skip if doesn't exist."
|
|
||||||
(declare (indent defun))
|
|
||||||
(unless values
|
|
||||||
(error "Empty @set for %s" keyword))
|
|
||||||
(let ((fn (intern (format "doom-setting--setter%s" keyword))))
|
|
||||||
(if (functionp fn)
|
|
||||||
(apply fn (eval `(list ,@values)))
|
|
||||||
(when doom-debug-mode
|
|
||||||
(message "No setting found for %s" keyword)))))
|
|
||||||
|
|
||||||
|
|
||||||
;; (defun describe-setting ()
|
|
||||||
;; (interactive)
|
|
||||||
;; ;; TODO
|
|
||||||
;; (error "Not implemented yet"))
|
|
||||||
|
|
|
@ -149,5 +149,35 @@ Examples:
|
||||||
(t (user-error "@associate invalid rules for mode [%s] (in %s) (match %s) (files %s)"
|
(t (user-error "@associate invalid rules for mode [%s] (in %s) (match %s) (files %s)"
|
||||||
mode in match files))))))
|
mode in match files))))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Provides a centralized configuration system that a) won't evaluate its
|
||||||
|
;; arguments if it doesn't need to (performance), b) won't complain if the
|
||||||
|
;; setting doesn't exist and c) is more elegant than a bunch of `@after' blocks,
|
||||||
|
;; which can cause intermittent stuttering in large quantities. I'm a fan of
|
||||||
|
;; concise, do-what-I-mean front-facing configuration, believe it or not.
|
||||||
|
;;
|
||||||
|
;; Plus, it can benefit from byte-compilation.
|
||||||
|
|
||||||
|
(defmacro @def-setting (keyword arglist &optional docstring &rest forms)
|
||||||
|
"Define a setting macro. Like `defmacro', this should return a form to be
|
||||||
|
executed when called with `@set'. FORMS are not evaluated until `@set' calls it."
|
||||||
|
(declare (indent defun) (doc-string 3))
|
||||||
|
(unless (keywordp keyword)
|
||||||
|
(error "Not a valid property name: %s" keyword))
|
||||||
|
`(defun ,(intern (format "doom-setting--setter%s" keyword)) ,arglist
|
||||||
|
,docstring
|
||||||
|
,@forms))
|
||||||
|
|
||||||
|
(defmacro @set (keyword &rest values)
|
||||||
|
"Set an option defined by `@def-setting'. Skip if doesn't exist."
|
||||||
|
(declare (indent defun))
|
||||||
|
(unless values
|
||||||
|
(error "Empty @set for %s" keyword))
|
||||||
|
(let ((fn (intern (format "doom-setting--setter%s" keyword))))
|
||||||
|
(if (functionp fn)
|
||||||
|
(apply fn (eval `(list ,@values)))
|
||||||
|
(when doom-debug-mode
|
||||||
|
(message "No setting found for %s" keyword)))))
|
||||||
|
|
||||||
(provide 'core-lib)
|
(provide 'core-lib)
|
||||||
;;; core-lib.el ends here
|
;;; core-lib.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue