104 lines
3.4 KiB
EmacsLisp
104 lines
3.4 KiB
EmacsLisp
;;; acdw-setup.el -- my `setup' commands -*- lexical-binding: t -*-
|
|
|
|
;; Author: Case Duckworth <(rot13-string "npqj@npqj.arg")>
|
|
|
|
;; 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.
|
|
|
|
;;; Commentary:
|
|
|
|
;; setup.el makes defining local macros for `setup' forms quite simple, at
|
|
;; least to my mind. Here are some of the ones I've defined.
|
|
|
|
;;; Code:
|
|
|
|
(require 'setup)
|
|
|
|
(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 :require-after
|
|
(lambda (seconds)
|
|
`(run-with-idle-timer ,seconds nil
|
|
#'require ',(setup-get 'feature) nil t))
|
|
:documentation "Requre FEATURE, after SECONDS idle time.")
|
|
|
|
(setup-define :face
|
|
(lambda (face spec)
|
|
`(custom-set-faces '(,face ,spec 'now "Customized by `setup'.")))
|
|
:documentation "Customize FACE with SPEC using `custom-set-faces'."
|
|
: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)
|
|
`(unless (straight-use-package ',recipe)
|
|
,(setup-quit)))
|
|
: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-when
|
|
(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
|
|
:indent 1
|
|
:shorthand (lambda (sexp)
|
|
(let ((recipe (cadr sexp)))
|
|
(if (consp recipe) (car recipe) recipe))))
|
|
|
|
;; https://www.emacswiki.org/emacs/SetupEl
|
|
(setup-define :load-after
|
|
(lambda (&rest features)
|
|
(let ((body `(require ',(setup-get 'feature))))
|
|
(dolist (feature (if (listp features)
|
|
(nreverse features)
|
|
(list features)))
|
|
(setq body `(with-eval-after-load ',feature ,body)))
|
|
body))
|
|
:documentation "Load the current feature after FEATURES.")
|
|
|
|
(provide 'acdw-setup)
|
|
;;; acdw-setup.el ends here
|