From 0795827092ebe03944e1f0f1407648e657d4320c Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 7 Jul 2015 14:12:08 +0430 Subject: [PATCH] basic extension structure and loader added --- TODO.org | 1 + fg42-config.el | 11 ++--------- lib/extensions/editor.el | 12 ++++++++++++ lib/fg42.el | 30 ++++++++++++++++++++++++++++++ lib/fg42/base.el | 19 +++++++++++++++++++ lib/fg42/extension.el | 17 +++++++++++++++++ lib/fpkg.el | 10 +++++++--- 7 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 lib/extensions/editor.el create mode 100644 lib/fg42.el create mode 100644 lib/fg42/base.el create mode 100644 lib/fg42/extension.el diff --git a/TODO.org b/TODO.org index 0d2162d..98462c9 100644 --- a/TODO.org +++ b/TODO.org @@ -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 diff --git a/fg42-config.el b/fg42-config.el index 8ca6933..86d2953 100644 --- a/fg42-config.el +++ b/fg42-config.el @@ -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) diff --git a/lib/extensions/editor.el b/lib/extensions/editor.el new file mode 100644 index 0000000..bf7b004 --- /dev/null +++ b/lib/extensions/editor.el @@ -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) + diff --git a/lib/fg42.el b/lib/fg42.el new file mode 100644 index 0000000..7cefec0 --- /dev/null +++ b/lib/fg42.el @@ -0,0 +1,30 @@ +;;; FG42 --- a simple package manager for FG42 -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 lxsameer + +;; Author: Nic Ferrier +;; 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 . + +;;; Commentary: + +;; An Editor/IDE bundle base on Lovely Gnu/Emacs to make your life easier + +;;; Code: +(require 'fpkg) +(require 'fg42/base) + +(provide 'fg42) diff --git a/lib/fg42/base.el b/lib/fg42/base.el new file mode 100644 index 0000000..c1537dd --- /dev/null +++ b/lib/fg42/base.el @@ -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) diff --git a/lib/fg42/extension.el b/lib/fg42/extension.el new file mode 100644 index 0000000..b12de12 --- /dev/null +++ b/lib/fg42/extension.el @@ -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) diff --git a/lib/fpkg.el b/lib/fpkg.el index 3d7f725..4056f64 100644 --- a/lib/fpkg.el +++ b/lib/fpkg.el @@ -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)