From 713468a5bedb1dc0959fd2bab951c8f384aa3c82 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 3 Mar 2020 11:48:27 +0000 Subject: [PATCH] Actions and new extension data structures have been added --- lib/fg42/actions.el | 54 +++++++++++++++++++++++++++++++++++++++++++ lib/fg42/extension.el | 48 +++++++++++++++++++++++++++++++------- 2 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 lib/fg42/actions.el diff --git a/lib/fg42/actions.el b/lib/fg42/actions.el new file mode 100644 index 0000000..ff2e249 --- /dev/null +++ b/lib/fg42/actions.el @@ -0,0 +1,54 @@ +;;; actions --- Extension action library of FG42 +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; 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 . +;; +;;; Acknoledgement: +;; This library is heavily inspired by Kite mini library. Kudos Tung Dao +;; for his great work. +;; +;;; Commentary: +;;; Code: + +(require 'cl-lib) + + +(cl-defstruct fg42-actions + "This data structure contains all the actions that are common +among different extensions." + ;; A function that starts the development server for the given extension if + ;; there's any. + (start-lang-sever nil) + + ;; A function that stops the development server for the given extension if + ;; there's any. + (stop-lang-sever nil) + + ;; Action for inserting a print expr in the code + (print-expr nil)) + + +(defmacro actions (&rest body) + "A simple DSL to define a list of actions for an extension and BODY." + ;(declare (doc-string 1) (indent 1)) + `(setq ,name (apply 'make-fg42-extension :name ,(symbol-name name) (quote ,args)))) + + +(provide 'fg42/actions) +;;; actions.el ends here diff --git a/lib/fg42/extension.el b/lib/fg42/extension.el index 9aaa5b4..c54ac92 100644 --- a/lib/fg42/extension.el +++ b/lib/fg42/extension.el @@ -1,4 +1,28 @@ ;;; extension --- Extension library of FG42 +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; 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 . +;; +;;; Acknoledgement: +;; This library is heavily inspired by Kite mini library. Kudos Tung Dao +;; for his great work. +;; ;;; Commentary: ;;; Code: @@ -12,23 +36,31 @@ (defvar disabled-abilities (make-hash-table) "A hash of all the disabled abilities.") -;; TODO: add a function to extension structure to support for -;; external dependenies list ;; Structures ----------------------------- (cl-defstruct fg42-extension "Each FG42 extension should implement a copy of this structure." name + + ;; Let's keep this field for backward compatiblity for a while docs + + ;; Each extension should expose a info page. + doc-index + ;; Projectile provides a project type that we can use to + ;; activate/load the extensions based on their registered + ;; type. + project-types + (version nil) - ;; Describes - (major-modes nil) + + ;; An instance of fg42-actions structure that describe the + ;; different actions of the given extension + (actions nil) + ;; Callbacks (on-initialize nil) (on-load) - ;; An associated array of major modes to their - ;; debugger function - (print-debugger nil)) - + (on-unload)) ;; Functions ------------------------------ (defun active-ability? (name)