Add System datastructure and its namespace

This commit is contained in:
Sameer Rahmani 2020-03-20 22:35:34 +00:00
parent 56f908ddf5
commit dbcda8c755
2 changed files with 74 additions and 1 deletions

67
lib/fg42/system.el Normal file
View File

@ -0,0 +1,67 @@
;;; system --- System library of FG42
;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 0.1.0
;;
;; 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/>.
;;
;;; Acknoledgement:
;; This library is heavily inspired by Kite mini library. Kudos Tung Dao
;; for his great work.
;;
;;; Commentary:
;;; Code:
(require 'cl-lib)
(require 'fg42/utils)
(defun start-system (system)
"Start the given SYSTEM.
This is the default function to boot a system. Each system might
provide a different function to boo rather than this one."
(require 'fg42))
(cl-defstruct fg42-system
"A `system' describes a FG42 instance. Everything that is needed
to load FG42."
name
(packages '())
(abilities '())
;; A function which takes the `system' and starts it.
(start 'start-system)
(stop nil))
(defmacro defsystem (name &optional docstring &rest body)
"Define a system with the given NAME, DOCSTRING and BODY."
(declare (doc-string 2) (indent 1))
`(setq ,name (apply 'make-fg42-system
:name ,(symbol-name name)
(quote ,body))))
(comment
(defsystem FG42
"docstring"
:packages '(('elisp-extension :version "1.3.3"))
:abilities '()))
(provide 'fg42/system)
;;; system.el ends here

View File

@ -76,10 +76,16 @@
(fpkg-initialize)))
(defun depends-on (pkgname)
(defun depends-on1 (pkgname)
"Install the given PKGNAME if it isn't installed."
(straight-use-package pkgname))
(defmacro depends-on (pkgdesc)
`(progn
(straight-use-package ,@pkgdesc)))
(macroexpand '(depends-on 'sam))
(provide 'fpkg)
;;; fpkg.el ends here