summary refs log tree commit diff stats
path: root/lisp/acdw-setup.el
blob: aa5c5f519c5b1a6f30cecb1999b154ea2d0b9489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; acdw-setup.el -- my `setup' commands -*- lexical-binding: t -*-

;; Author: Case Duckworth <acdw@acdw.net>

;; 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 :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)
    `(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