basic extension structure and loader added

This commit is contained in:
Sameer Rahmani 2015-07-07 14:12:08 +04:30
parent 7fd8cf5990
commit 0795827092
7 changed files with 88 additions and 12 deletions

View File

@ -1,4 +1,5 @@
* Tasks
** Create different hash tables for packages with different source like github
** Workgroups
*** TODO Add a directory scanning mode. load each workgroup by name only.
** TODO Provide a variable (defcustom) which allow user to easily change them from customize menu

View File

@ -1,13 +1,6 @@
(add-to-list 'load-path "./lib")
(toggle-debug-on-error)
(require 'fpkg)
(require 'fg42)
(depends-on "f"
:version "0"
:path "asdasdasd")
(enable-extensions 'editor)
(describe-variable 'required-packages)
;(require 'cask "~/.cask/cask.el")
;(cask-initialize "/home/lxsameer/src/FG42/FG42/")
;(require 'fg42-core)

12
lib/extensions/editor.el Normal file
View File

@ -0,0 +1,12 @@
(require 'fg42/extension)
(defun extension/editor-initialize ()
"Base plugin initialization."
(message "inside init"))
(extension editor
:version "2.67"
:on-initialize extension/editor-initialize)
(provide 'extensions/editor)

30
lib/fg42.el Normal file
View File

@ -0,0 +1,30 @@
;;; FG42 --- a simple package manager for FG42 -*- lexical-binding: t; -*-
;; Copyright (C) 2015 lxsameer
;; Author: Nic Ferrier <lxsameer@gnu.org>
;; Keywords: lisp fg42 IDE package manager
;; Version: 2.67.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/>.
;;; Commentary:
;; An Editor/IDE bundle base on Lovely Gnu/Emacs to make your life easier
;;; Code:
(require 'fpkg)
(require 'fg42/base)
(provide 'fg42)

19
lib/fg42/base.el Normal file
View File

@ -0,0 +1,19 @@
(require 'cl-lib)
(require 'fg42/extension)
(defun load--extension (extension)
"Load a single extension and call its :on-initialize function"
(let ((lib (concat "extensions/" (symbol-name extension)))
(init-func nil))
(require (intern lib))
(setq init-func (fg42-extension-on-initialize (symbol-value extension)))
(funcall (symbol-function init-func))))
(defun enable-extensions (&rest extensions)
"Mark given plugins to load on FG42"
(mapcar 'load--extension extensions))
(provide 'fg42/base)

17
lib/fg42/extension.el Normal file
View File

@ -0,0 +1,17 @@
;; This library provides some basic means to create a new FG42 extensions
(require 'cl-lib)
;; Structures -----------------------------
(cl-defstruct fg42-extension
"Each FG42 extension should implement a copy of this structure."
name
(version nil)
;; Callbacks
(on-initialize nil)
(on-load))
(defmacro extension (name &rest args)
"A simple DSL to define new fg42 extension."
`(setq ,name (apply 'make-fg42-extension :name ,(symbol-name name) (quote ,args))))
(provide 'fg42/extension)

View File

@ -42,12 +42,16 @@
;; Functions ----------------------------------
(defun fpkg-initialize ()
"Initilize the package.el and related stuff to be used in FG42"
)
(require 'package)
(require 'melpa)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize))
(defun depends-on (pkgname &rest args)
"Global function to specify a single dependency"
(let ((pkg (apply 'make-fpkg-dependency :name pkgname args)))
(puthash pkgname pkg required-packages)))
(provide 'fpkg)