-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mic-adapter.el
99 lines (86 loc) · 3.75 KB
/
mic-adapter.el
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
;;; mic-adapter.el --- Adapters for mic -*- lexical-binding: t; -*-
;; Copyright (C) 2023 by ROCKTAKEY
;; Author: ROCKTAKEY <ROCKTAKEY@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Adapters for mic
;;; Code:
(require 'mic-utils)
(defun mic-adapter-use-package (plist)
"An adapter from `mic-core'-like input PLIST to `use-package'.
It takes one argument PLIST, and transforms it into `use-package' sexp."
(let ((eval (plist-get plist :eval))
;; Variable named `eval-after-load' is warned by `package-lint', so use `eal' instead.
(eal (plist-get plist :eval-after-load))
(eval-after-others (plist-get plist :eval-after-others))
(eval-after-others-after-load (plist-get plist :eval-after-others-after-load))
(eval-before-all (plist-get plist :eval-before-all))
(eval-installation (plist-get plist :eval-installation))
(rest-plist plist))
(mic-plist-delete rest-plist
:eval
:eval-after-load
:eval-after-others
:eval-after-others-after-load
:eval-before-all
:eval-installation
:defer)
`(,@rest-plist
:defer ,(if (plist-member plist :defer) (plist-get plist :defer) t)
,@(when (or eval-before-all eval-installation)
`(:preface
,@eval-before-all
,@eval-installation))
,@(when (or eval eval-after-others)
`(:init
,@eval
,@eval-after-others))
,@(when (or eal eval-after-others-after-load)
`(:config
,@eal
,@eval-after-others-after-load)))))
(defun mic-adapter-leaf (plist)
"An adapter from `mic-core'-like input PLIST to `leaf'.
It takes one argument PLIST, and transforms it into `leaf' sexp."
(let ((eval (plist-get plist :eval))
;; Variable named `eval-after-load' is warned by `package-lint', so use `eal' instead.
(eal (plist-get plist :eval-after-load))
(eval-after-others (plist-get plist :eval-after-others))
(eval-after-others-after-load (plist-get plist :eval-after-others-after-load))
(eval-before-all (plist-get plist :eval-before-all))
(eval-installation (plist-get plist :eval-installation))
(rest-plist plist))
(mic-plist-delete rest-plist
:eval
:eval-after-load
:eval-after-others
:eval-after-others-after-load
:eval-before-all
:eval-installation)
`(,@rest-plist
,@(when (or eval-before-all eval-installation)
`(:preface
,@eval-before-all
,@eval-installation))
,@(when (or eval eval-after-others)
`(:init
,@eval
,@eval-after-others))
,@(when (or eal eval-after-others-after-load)
`(
;; Sometimes :config is not wrapped around `with-eval-after-load',
;; so use :defer-config instead.
:defer-config
,@eal
,@eval-after-others-after-load)))))
(provide 'mic-adapter)
;;; mic-adapter.el ends here