From 6a6d966432a8aa9298c814bc976d988f7cdef4aa Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 3 Sep 2021 22:50:58 -0500 Subject: Move setup-defines into acdw-setup.el --- lisp/acdw-setup.el | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lisp/acdw-setup.el (limited to 'lisp') diff --git a/lisp/acdw-setup.el b/lisp/acdw-setup.el new file mode 100644 index 0000000..ca30249 --- /dev/null +++ b/lisp/acdw-setup.el @@ -0,0 +1,71 @@ +;;; acdw-setup.el -- my `setup' commands -*- lexical-binding: t -*- + +;; Author: Case Duckworth + +;; This file is NOT part of GNU Emacs. + +;;; License: +;; Everyone is permitted to do whatever with this software, without +;; limitation. This software comes without any warranty whatsoever, +;; but with two pieces of advice: +;; - Don't hurt yourself. +;; - Make good choices. + +;;; Code: + +(setup-define :autoload + (lambda (func) + (if (listp func) + (let ((plist (cdr func))) + `(autoload ',(car func) + ,(symbol-name (setup-get 'feature)) + ,(plist-get plist :docstring) + ,(plist-get plist :interactive) + ,(plist-get plist :type))) + `(autoload ',func ,(symbol-name (setup-get 'feature))))) + :documentation "Autoload FUNC from FEATURE. +`:autoload' can be passed a list with keywords: +:docstring - The DOCSTRING to give the autoloaded function. +:interactive - Whether the function is INTERACTIVE or not. +:type - Either `nil', `keymap', or `macro': see `autoload' for details." + :repeatable t) + +(setup-define :file-match + ;; Hotfix; patch here: https://github.com/phikal/setup.el/pull/1 + (lambda (pat) + `(add-to-list 'auto-mode-alist (cons ,pat ',(setup-get 'mode)))) + :documentation "Associate the current mode with files that match PAT." + :debug '(form) + :repeatable t) + +(setup-define :straight + (lambda (recipe) + `(straight-use-package ',recipe)) + :documentation + "Install RECIPE with `straight-use-package'. +This macro can be used as HEAD, and will replace itself with the +first RECIPE's package." + :repeatable t + :shorthand (lambda (sexp) + (let ((recipe (cadr sexp))) + (if (consp recipe) + (car recipe) + recipe)))) + +(setup-define :straight-if + (lambda (recipe condition) + `(if ,condition + (straight-use-package ',recipe) + ,(setup-quit))) + :documentation + "Install RECIPE with `straight-use-package' when CONDITION is met. +If CONDITION is false, stop evaluating the body. This macro can +be used as HEAD, and will replace itself with the RECIPE's +package. This macro is not repeatable." + :repeatable nil + :shorthand (lambda (sexp) + (let ((recipe (cadr sexp))) + (if (consp recipe) (car recipe) recipe)))) + +(provide 'acdw-setup) +;;; acdw-setup.el ends here -- cgit 1.4.1-21-gabe81