From f17dd3984eff18377fedf6f4e3471350f8682bc9 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 14 Apr 2020 20:09:47 +0100 Subject: [PATCH 01/12] Add a bare minimum system implementation for V3 Signed-off-by: Sameer Rahmani --- core/fg42.el | 39 ++++++++++++ core/fg42/extensions.el | 91 +++++++++++++++++++++++++++ core/fg42/extensions/core.el | 91 +++++++++++++++++++++++++++ core/fg42/system.el | 61 +++++++++++++++++++ core/fg42/system/core.el | 72 ++++++++++++++++++++++ core/fg42/system/utils.el | 47 ++++++++++++++ core/fg42/utils.el | 115 +++++++++++++++++++++++++++++++++++ extensions/fg42-elisp | 1 + fg42-new | 9 +++ system.el | 39 ++++++++++++ 10 files changed, 565 insertions(+) create mode 100644 core/fg42.el create mode 100644 core/fg42/extensions.el create mode 100644 core/fg42/extensions/core.el create mode 100644 core/fg42/system.el create mode 100644 core/fg42/system/core.el create mode 100644 core/fg42/system/utils.el create mode 100644 core/fg42/utils.el create mode 160000 extensions/fg42-elisp create mode 100755 fg42-new create mode 100644 system.el diff --git a/core/fg42.el b/core/fg42.el new file mode 100644 index 0000000..3f0bbf9 --- /dev/null +++ b/core/fg42.el @@ -0,0 +1,39 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;;; Code: +(require 'fg42/system/utils) + +(autoload 'fg42-system/start "fg42/system" + "Starts the given SYSTEM.") + + +(defun fg42/start! (system) + "Start the given SYSTEM description." + (fg42-system/set-system! system) + + (add-hook 'window-setup-hook + (lambda () (fg42-system/start)))) + + +(provide 'fg42) +;;; fg42.el ends here diff --git a/core/fg42/extensions.el b/core/fg42/extensions.el new file mode 100644 index 0000000..845f814 --- /dev/null +++ b/core/fg42/extensions.el @@ -0,0 +1,91 @@ +;;; extensions --- Extension library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;;; Code: + +;; This library provides some basic means to create a new FG42 extensions +(require 'fg42/utils) +(require 'fg42/extensions/core) + + +(defun fg42-extensions/load-index (system ext-name ext-path) + "Load the extension EXT-NAME which is in EXT-PATH using SYSTEM. +It will load the main file of the extension and return the `fg42-extension' +instance of the extension and nil otherwise." + (let ((is-loaded? (require ext-name ext-path t))) + (when is-loaded? + (symbol-value ext-name)))) + + +(defun fg42-extensions/load-extension (system ext) + "Setup the given extension EXT against the given SYSTEM. +At this stage we will install/load the main file of the extensions +and call the `on-initialize'function of extensions in order to setup +the autoloads and hooks." + (cond + ((symbolp ext) + (fg42-extensions/load-index system ext (fg42-extension/path system ext))) + + ((listp ext) + (fg42-extensions/load-index system (car ext) (cadr ext))) + (t + ;; TODO: instead of throwing and error, inject the error into the system + (throw 'load-extension-failed + (format "Can't load extension %s" (str ext)))))) + + +(defun fg42-extensions/load-system-extensions (system) + "Load the extensions defined in the given SYSTEM. + +SYSTEM should be an instance of `fg42-system' which contains a list +of extension names on the `extensions' field. This function finds and +loads the index file of those extensions and returns a new system +containing the `fg42-extension' instances." + (let ((exts (mapcar (lambda (ext) + (fg42-extensions/load-extension system ext)) + (fg42-system-extensions system)))) + (setf (fg42-system-extensions system) + exts)) + system) + + +(defun fg42-extensions/initialize (system ext) + "Initialize the given extension EXT aginst the given SYSTEM." + (funcall (fg42-extension-on-initialize ext) system)) + + +(defun fg42-extensions/initialize-extensions (system) + "Initialize the extensions within SYSTEM and return a new system." + (mapcar + (lambda (ext) (fg42-extensions/initialize system ext)) + (fg42-system-extensions system)) + system) + + +(defun fg42-setup-extensions (system) + "Setup the preloads for the given SYSTEM." + (funcall (comp #'fg42-extensions/initialize-extensions + #'fg42-extensions/load-system-extensions) system)) + + +(provide 'fg42/extensions) +;;; extensions.el ends here diff --git a/core/fg42/extensions/core.el b/core/fg42/extensions/core.el new file mode 100644 index 0000000..329d0b6 --- /dev/null +++ b/core/fg42/extensions/core.el @@ -0,0 +1,91 @@ +;;; extensions --- Extension library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;;; Code: + +(require 'cl-lib) +(require 'fg42/system/core) + + +(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 + ;; To be used with `describe-extension' + (docstring nil) + ;; Projectile provides a project type that we can use to + ;; activate/load the extensions based on their registered + ;; type. + project-types + + (version nil) + + ;; An instance of fg42-actions structure that describe the + ;; different actions of the given extension + (actions nil) + (path nil) + ;; Callbacks + (on-initialize nil) + (on-load) + (on-unload)) + + +(defun fg42-extensions/build-path (system ext) + "Build a path for the given EXT name (symbol) via SYSTEM info." + ;; TODO: should we extract variables such as `fg42-home' to their + ;; dedicated ns in order to avoid the warning ? + (let ((ext-name (symbol-name ext))) + (concat (fg42-system-root) + "/extensions/" ext-name "/" ext-name ".el"))) + + +(defun fg42-extension/path (system ext) + "Return the path to the given extension EXT in the given SYSTEM." + (cond + ((symbolp ext) (fg42-extension/build-path system ext)) + ((fg42-extension-p ext) + (or (fg42-extension-path ext) + (fg42-extension/build-path system + (intern (fg42-extension-name ext))))))) + + +(defmacro defextension (name docstring &rest args) + "A simple DSL to define new fg42 extension by given NAME, DOCSTRING and ARGS." + (declare (doc-string 2) (indent 1)) + ;; TODO: Inject the docstring to the current `system' in order + ;; to collect it later for `describe-extension' function. + (when (not (stringp docstring)) + (throw 'extention-error + "`docstring' is mandatory and it should be a string.")) + `(setq ,name (apply 'make-fg42-extension + :name ,(symbol-name name) + :docstring ,docstring + (quote ,args)))) + + +(provide 'fg42/extensions/core) +;;; core.el ends here diff --git a/core/fg42/system.el b/core/fg42/system.el new file mode 100644 index 0000000..df731eb --- /dev/null +++ b/core/fg42/system.el @@ -0,0 +1,61 @@ +;;; system --- System library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;; `System' is just a state monad which holds the state of the editor. +;; Each system has to have a `start' function to start the setup process. +;; +;;; Code: + +(require 'fg42/utils) +(require 'fg42/system/core) +(require 'fg42/system/utils) + + +(defun fg42-system/start () + "Start the system from `fg42-get-current-system'." + (debug-message "Starting the default system.") + (let ((sys (fg42-system/get-active-system))) + (funcall (fg42-system-start sys) sys))) + + +(comment + (macroexpand-1 '(defsystem testsystem + "docstring" + :preloads '(2 43 4) + :packages '(('elisp-extension :version "1.3.3")) + :abilities '())) + (defsystem testsystem + "docstring1" + :packages '(('elisp-extension :version "1.3.3")) + :abilities '()) + + (make-fg42-system :name "asd" :preloads '(213 452) :abilities '(x y)) + (aset testsystem 2 "sam") + (setf (fg42-system-abilities testsystem) '(3 3 3 3 3)) + (fg42-set-current-system! testsystem) + (fg42-system-preloads testsystem) + (start-system) + (fg42-system-start testsystem)) + + +(provide 'fg42/system) +;;; system.el ends here diff --git a/core/fg42/system/core.el b/core/fg42/system/core.el new file mode 100644 index 0000000..afcee61 --- /dev/null +++ b/core/fg42/system/core.el @@ -0,0 +1,72 @@ +;;; system --- System library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;; `System' is just a state monad which holds the state of the editor. +;; Each system has to have a `start' function to start the setup process. +;; +;;; Code: + +(require 'cl-lib) +(require 'fg42/utils) + + +(cl-defstruct fg42-system + "A `system' describes a FG42 instance. Everything that is needed +to load FG42." + name + + ;; We will use this value for `describe-system' as a short + ;; documentation. + docstring + + ;; TODO: guess the system root based on the `name' field + ;; as the default value + (root (concat (getenv "HOME") "/.fg42")) + + ;; The directory to store all sort of temporary files including + ;; backups, flycheck temps and stuff like that. + (tmp-path "~/.tmp") + + (packages '()) + ;; ;; A list of preloads to setup extensions which are not loaded yet. + ;; ;; For more information on preloads checkout `fg42/extension' + ;; (preloads '()) + + (extensions '()) + (abilities '()) + ;; A function which takes the `system' and starts it. + (start (lambda (system) 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)) + (let ((form (if (boundp (intern (format "%s" name))) 'setq 'defvar))) + `(,form ,name (make-fg42-system + :name ,(symbol-name name) + :docstring ,docstring + ,@body)))) + + +(provide 'fg42/system/core) +;;; core.el ends here diff --git a/core/fg42/system/utils.el b/core/fg42/system/utils.el new file mode 100644 index 0000000..2805b46 --- /dev/null +++ b/core/fg42/system/utils.el @@ -0,0 +1,47 @@ +;;; system --- System library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;; `System' is just a state monad which holds the state of the editor. +;; Each system has to have a `start' function to start the setup process. +;; +;;; Code: + +(defvar fg42-system/active--system nil + "A private variable to store the active system. +Use `fg42-get-current-system' instead") + + +(defun fg42-system/get-active-system () + "Return the current active system of FG42." + fg42-system/active--system) + + +(defun fg42-system/set-system! (system) + "Set the current system to the given SYSTEM." + ;; TODO: In the future when we moved to parallel boot + ;; we need to make sure that this funciton + ;; sets the state safely. + (setq fg42-system/active--system system)) + + +(provide 'fg42/system/utils) +;;; utils.el ends here diff --git a/core/fg42/utils.el b/core/fg42/utils.el new file mode 100644 index 0000000..49a4cee --- /dev/null +++ b/core/fg42/utils.el @@ -0,0 +1,115 @@ +;;; Utils --- Utils library of FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;; `System' is just a state monad which holds the state of the editor. +;; Each system has to have a `start' function to start the setup process. +;; +;;; Code: +(require 'cl-lib) + +;;; Buffer helpers ------------------------------------------------------------ +(defun buffer-mode (buffer-or-string) + "Return the major mode associated with a the given BUFFER-OR-STRING." + (with-current-buffer buffer-or-string + major-mode)) + + +(defun ->buffer (buffer-name data &optional fn) + "Insert the given DATA into the given buffer provided by BUFFER-NAME. + +It will create a the buffer if it doesn't exist. It will call the given FN +at the end in context of the buffer. This function accepts only one argument +with is the buffer." + (let ((buf (get-buffer-create buffer-name))) + (with-current-buffer buf + (insert data) + (when fn + (funcall fn buf))))) + + +(defmacro inspect-expression (&rest body) + "Pretty prints the result of the given BODY." + `(pp-display-expression ,@body (get-buffer-create fg42/inspect-buffer))) + + +(defun inspect-data-append (data) + "Append the given DATA to the inspection buffer with padding." + ;; TODO: Move 'fg42/inspect-buffer' to the somewhere propriate + ;; possiblly the system. + (->buffer + "fg42/inspect-buffer" + (format + "\n;; START ======================================================\n%s%s" + (pp-to-string data) + ";; END.\n"))) + + +(defun apply-face (face-symbol text) + "Apply the given FACE-SYMBOL to the given TEXT." + (put-text-property 0 (length text) 'face face-symbol text)) + + +(defmacro comment (&rest body) + "A macro similar to Clojure's comment macro that ignore the BODY." + (declare (indent 0)) + `nil) + + +(defmacro debug-message (&rest params) + "Print out the given PARAMS only if debug mode is on." + (if debug-on-error + `(message ,@params) + nil)) + + +(defmacro deprecated (msg &rest form) + "Mark the given FORM as deprecated with the given MSG." + (declare (indent 0)) + `(progn + (warn (format "[DEPRECATED]: %s" ,msg)) + ,@form)) + + +;; TODO: A good candidate for an inline function +(defun find-value-for (lst key) + "Return the value of the given KEY in the given LST. +For example for a list like (list :x 4 :y 5) we can find the value of +`:x' by doing `(get-value-for lst :x)'." + (let ((pairs (seq-partition lst 2))) + (when-let (pair (assq key pairs)) + (cadr pair)))) + + +(defun comp (&rest fns) + "Compose the given list of FNS into one function that accepts multiple values. +For example: + (funcall (compose (lambda (x) (+ 1 x)) (lambda (x) (* x s))) 5) +or + (funcall (compose #'some-fn #'message) some-value)" + (lambda (&rest values) + (reduce 'funcall (butlast fns) + :from-end t + :initial-value (apply (car (last fns)) values)))) + + +(provide 'fg42/utils) +;;; utils.el ends here diff --git a/extensions/fg42-elisp b/extensions/fg42-elisp new file mode 160000 index 0000000..721da6e --- /dev/null +++ b/extensions/fg42-elisp @@ -0,0 +1 @@ +Subproject commit 721da6e0a242eb6630dd476f2d8e1146d67d2e40 diff --git a/fg42-new b/fg42-new new file mode 100755 index 0000000..31a6d86 --- /dev/null +++ b/fg42-new @@ -0,0 +1,9 @@ +#! /bin/sh + +export FG42_HOME=/home/lxsameer/.fg42 +FG42_WM=false /home/lxsameer/src/emacs/build/bin/emacs --name FG42 \ + --no-site-file --no-site-lisp --no-splash --title FG42 \ + -L $FG42_HOME/core \ + -L $FG42_HOME/extensions \ + -l $FG42_HOME/core/fg42.el \ + -l ~/.v3.el "$@" diff --git a/system.el b/system.el new file mode 100644 index 0000000..9d289dd --- /dev/null +++ b/system.el @@ -0,0 +1,39 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;; Thanks to all the people who contributed to FG42. +;; +;;; Commentary: +;;; Code: + +(require 'fg42) +(require 'fg42/system/core) + + +(defsystem FG42 + "FG42 implemented in term of systems and this is the default system." + :start (lambda (system) (message "hooray!")) + :extensions '(fg42-elisp)) + + +(provide 'system) +;;; system.el ends here From a1c4b2a1064b4cfb2c4b8792e5d4577a4eb96b5a Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 14 Apr 2020 20:24:34 +0100 Subject: [PATCH 02/12] Add the CHANGELOG Signed-off-by: Sameer Rahmani --- CHANGELOG | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..cfb6511 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,16 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +### Added + - `System` implementation (`core/fg42/system.el`) + - New `extensions` implementation (`core/fg42/extensions.el`) + - New approach to launching fg42 +### Changed + - Changed the main package path to `/core` + - Changed the extensions path to `/extensions` + - We don't load `fg42-config.el` anymore + - We don't load anything from `/lib` anymore From 8757abe917c55e2798538c69919dc3f4273583f6 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 14 Apr 2020 22:37:00 +0100 Subject: [PATCH 03/12] Add the byte code compiler --- CHANGELOG | 1 + CONTRIBUTE | 144 ++++++++++++++++++++++++++++++++++++++++ Makefile | 4 ++ core/fg42/extensions.el | 2 +- core/fg42/system.el | 12 ++-- scripts/compiler.el | 30 +++++++++ 6 files changed, 186 insertions(+), 7 deletions(-) create mode 100644 CONTRIBUTE create mode 100644 scripts/compiler.el diff --git a/CHANGELOG b/CHANGELOG index cfb6511..4d788cc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `System` implementation (`core/fg42/system.el`) - New `extensions` implementation (`core/fg42/extensions.el`) - New approach to launching fg42 + - New `compiler` target to Makefile ### Changed - Changed the main package path to `/core` - Changed the extensions path to `/extensions` diff --git a/CONTRIBUTE b/CONTRIBUTE new file mode 100644 index 0000000..d7dd651 --- /dev/null +++ b/CONTRIBUTE @@ -0,0 +1,144 @@ +# Contribution Guidelines +*FG42* is a free software and a community of Emacs developers who like to share +their ideas and tools. We encourage you to join us. The community is what matters +to us. Here is a brief overview of contribution guidelines, which we ask all +contributors to follow. + +## Asking for help +If you want to ask an usage question, first make sure to read the `README.md` file +and the documents of *FG42*. If you still need help feel free to join us via +[out gitter channel](https://gitter.im/FG42/FG42). + +## Reporting issues +Issues have to be reported on our [issues tracker](https://gitlab.com/FG42/FG42/issues). Please: + +- Check that the issue has not already been reported. + - This can be achieved by searching keywords on the [issues tracker](https://gitlab.com/FG42/FG42/issues). +- Try to use a clear title, and describe your problem with complete sentences. + - Include your emacs version and `~/.fg42.el` file as well. + - If possible, try to include details on how to reproduce it, like a step by + step guide. + +## Contributing code +Code contributions are welcome. Please read the following sections carefully. In +any case, feel free to join us on [out gitter channel](https://gitter.im/FG42/FG42) to ask questions about +contributing! + +### General contribution + +#### License +The license is *GPLv2* for all parts specific to *FG42*, this includes: +- The initialization and core files +- All the built-in extensions. + +For files not belonging to FG42 like local packages and libraries, refer +to the header file. Those files should not have an empty header, we may not +accept code without a proper header file. + +#### Conventions +We follow these simple rules: + +* Make elisp linter happy +* follow functional patterns and avoid huge functions +* seperate each expression by two new lines +* put (comment ...) to demonstrate the usage of the function +* write good docstrings +* choose meaningful names +* follow the indentation guides made in FG42 +* prefix the functions with a prefix to differentiate them from other functions ( we need to discuss this) +* use -- for private/internal function names +* use / to categorize functions into namespaces ( air quote) + +#### Pull-Request +Submit your contribution against the `master` branch. The `stable` branch +is going to be our last stable version only. + +Please make one PR per feature. Keep your PRs as small as possible so we can review them +easily. + +Write commit messages according to adapted [this article](https://chris.beams.io/posts/git-commit/): + +- Include the extension or library name in the title inside square brackets +- Use present tense and write in the imperative: “Fix bug”, not “fixed bug” or + “fixes bug”. +- Start with a capitalized, short (72 characters or less) summary, followed by a + blank line. +- If necessary, add one or more paragraphs with details, wrapped at 72 + characters. +- Separate paragraphs by blank lines. + +This is a model commit message: + +``` +[FPKG] Capitalized, short (72 chars or less) summary + +More detailed explanatory text, if necessary. Wrap it to about 72 +characters or so. In some contexts, the first line is treated as the +subject of an email and the rest of the text as the body. The blank +line separating the summary from the body is critical (unless you omit +the body entirely); tools like rebase can get confused if you run the +two together. + +Write your commit message in the imperative: "Fix bug" and not "Fixed bug" +or "Fixes bug." This convention matches up with commit messages generated +by commands like git merge and git revert. + +Further paragraphs come after blank lines. + +- Bullet points are okay, too + + - Typically a hyphen or asterisk is used for the bullet, followed by a + single space, with blank lines in between, but conventions vary here + + - Use a hanging indent +``` + +[[https://github.com/magit/magit/][Git Commit]] and [[https://github.com/magit/magit/][Magit]] provide Emacs mode +for Git commit messages, which helps you to comply to these guidelines. + +### Contributing an extension +Technical aspects TBD + +Each file should be GPL compliant and contain the following header: + +```lisp +;;; FILENAME --- SHORT DESCRIPTION +;; +;; Copyright (c) 2010-2020 Sameer Rahmani & Contributors +;; +;; Author: YOUR FULL NAME +;; URL: https://gitlab.com/FG42/FG42 +;; Version: VERSION +;; +;; 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: +;; THE COMMENTARY ON THE MOST IMPORTANT ASPECT OF THE EXTENSION +;; +;;; Code: +``` + +You should replace `FILENAME` by the name of the file (e.g. `packages.el`). +Don't forget to replace `YOUR FULL NAME` and `YOUR EMAIL` also. + +#### Contribute to an existing extension +If you are contributing to an already existing extension, you should not modify any +header file. + +* Credits + +This `CONTRIBUTING` file is partially based on the [Rails Contribution +guidelines](https://github.com/rails/rails/blob/master/CONTRIBUTING.md) +and [Flycheck Contribution guidelines](https://github.com/flycheck/flycheck/blob/master/CONTRIBUTING.md) +and [Spacemacs Contribution guidelines](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/CONTRIBUTING.org). diff --git a/Makefile b/Makefile index 99c3911..e1b1009 100644 --- a/Makefile +++ b/Makefile @@ -51,3 +51,7 @@ install: install-fonts: @mkdir -p ~/.fonts/ @cp -rv ./share/fonts/vazir/* ~/.fonts/ + +.PHONY: compile +compile: + @$(PWD)/fg42-new --script scripts/compiler.el diff --git a/core/fg42/extensions.el b/core/fg42/extensions.el index 845f814..9710ad4 100644 --- a/core/fg42/extensions.el +++ b/core/fg42/extensions.el @@ -27,7 +27,7 @@ (require 'fg42/extensions/core) -(defun fg42-extensions/load-index (system ext-name ext-path) +(defun fg42-extensions/load-index (_system ext-name ext-path) "Load the extension EXT-NAME which is in EXT-PATH using SYSTEM. It will load the main file of the extension and return the `fg42-extension' instance of the extension and nil otherwise." diff --git a/core/fg42/system.el b/core/fg42/system.el index df731eb..a1e8ae9 100644 --- a/core/fg42/system.el +++ b/core/fg42/system.el @@ -1,6 +1,6 @@ ;;; system --- System library of FG42 -*- lexical-binding: t; -*- ;; -;; Copyright (c) 2010-2020 Sameer Rahmani +;; Copyright (c) 2010-2020 Sameer Rahmani & Contributors ;; ;; Author: Sameer Rahmani ;; URL: https://gitlab.com/FG42/FG42 @@ -25,13 +25,13 @@ ;; ;;; Code: -(require 'fg42/utils) -(require 'fg42/system/core) -(require 'fg42/system/utils) - - +;;;###autoload (defun fg42-system/start () "Start the system from `fg42-get-current-system'." + (require 'fg42/utils)) + (require 'fg42/system/core) + (require 'fg42/system/utils) + (debug-message "Starting the default system.") (let ((sys (fg42-system/get-active-system))) (funcall (fg42-system-start sys) sys))) diff --git a/scripts/compiler.el b/scripts/compiler.el new file mode 100644 index 0000000..2ef295c --- /dev/null +++ b/scripts/compiler.el @@ -0,0 +1,30 @@ +;;; FG42ByteCompiler --- The byte compiler for FG42 libraries and extensions +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;;; Code: + +(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core")) + +(message "Compiling FG42 core...") +(byte-recompile-directory (concat (getenv "FG42_HOME") "/core") 0 t) +;;; compiler.el ends here From ea8126c23e17251afdf35710fafea35632fdf9ce Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 14 Apr 2020 22:40:40 +0100 Subject: [PATCH 04/12] Add minor changes to CONTRIBUTE around coding styles --- CONTRIBUTE | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTE b/CONTRIBUTE index d7dd651..7977911 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -39,15 +39,16 @@ accept code without a proper header file. We follow these simple rules: * Make elisp linter happy -* follow functional patterns and avoid huge functions -* seperate each expression by two new lines -* put (comment ...) to demonstrate the usage of the function -* write good docstrings -* choose meaningful names -* follow the indentation guides made in FG42 -* prefix the functions with a prefix to differentiate them from other functions ( we need to discuss this) -* use -- for private/internal function names -* use / to categorize functions into namespaces ( air quote) +* Follow functional patterns and avoid huge functions +* Seperate each root level expression by two new lines (e.g function definitions) +* Put `(comment ...)` expression after each macro/function to demonstrate the usage. +* Write good docstrings +* Choose meaningful names +* Follow the indentation guides made in FG42 +* Prefix the functions with a prefix to differentiate them from other functions. + for example `fg42-namespace/functoin-name`. +* use `/-` for private/internal function names +* use `/` to categorize functions into namespaces (air quote) #### Pull-Request Submit your contribution against the `master` branch. The `stable` branch From fc233d834e5df50eca0934d206cd5ae205d8c7da Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 12:08:13 +0100 Subject: [PATCH 05/12] Fix compilation warnings for system/extension libs --- Makefile | 5 +++++ core/fg42/extensions.el | 6 +++--- core/fg42/extensions/core.el | 10 +++++----- core/fg42/system.el | 22 +--------------------- core/fg42/utils.el | 19 ++++++++++++++----- 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index e1b1009..b82ba64 100644 --- a/Makefile +++ b/Makefile @@ -55,3 +55,8 @@ install-fonts: .PHONY: compile compile: @$(PWD)/fg42-new --script scripts/compiler.el + +.PHONY: clean +clean: + @rm -rf $(shell find `pwd` -iname "*~") + @rm -rf $(shell find `pwd`/core -iname "*.elc") diff --git a/core/fg42/extensions.el b/core/fg42/extensions.el index 9710ad4..c8faea6 100644 --- a/core/fg42/extensions.el +++ b/core/fg42/extensions.el @@ -43,14 +43,14 @@ and call the `on-initialize'function of extensions in order to setup the autoloads and hooks." (cond ((symbolp ext) - (fg42-extensions/load-index system ext (fg42-extension/path system ext))) + (fg42-extensions/load-index system ext (fg42-extensions/path system ext))) ((listp ext) (fg42-extensions/load-index system (car ext) (cadr ext))) (t ;; TODO: instead of throwing and error, inject the error into the system (throw 'load-extension-failed - (format "Can't load extension %s" (str ext)))))) + (format "Can't load extension %s" (->str ext)))))) (defun fg42-extensions/load-system-extensions (system) @@ -75,7 +75,7 @@ containing the `fg42-extension' instances." (defun fg42-extensions/initialize-extensions (system) "Initialize the extensions within SYSTEM and return a new system." - (mapcar + (mapc (lambda (ext) (fg42-extensions/initialize system ext)) (fg42-system-extensions system)) system) diff --git a/core/fg42/extensions/core.el b/core/fg42/extensions/core.el index 329d0b6..6a5a530 100644 --- a/core/fg42/extensions/core.el +++ b/core/fg42/extensions/core.el @@ -59,18 +59,18 @@ ;; TODO: should we extract variables such as `fg42-home' to their ;; dedicated ns in order to avoid the warning ? (let ((ext-name (symbol-name ext))) - (concat (fg42-system-root) + (concat (fg42-system-root system) "/extensions/" ext-name "/" ext-name ".el"))) -(defun fg42-extension/path (system ext) +(defun fg42-extensions/path (system ext) "Return the path to the given extension EXT in the given SYSTEM." (cond - ((symbolp ext) (fg42-extension/build-path system ext)) + ((symbolp ext) (fg42-extensions/build-path system ext)) ((fg42-extension-p ext) (or (fg42-extension-path ext) - (fg42-extension/build-path system - (intern (fg42-extension-name ext))))))) + (fg42-extensions/build-path system + (intern (fg42-extension-name ext))))))) (defmacro defextension (name docstring &rest args) diff --git a/core/fg42/system.el b/core/fg42/system.el index a1e8ae9..ac87e53 100644 --- a/core/fg42/system.el +++ b/core/fg42/system.el @@ -28,7 +28,7 @@ ;;;###autoload (defun fg42-system/start () "Start the system from `fg42-get-current-system'." - (require 'fg42/utils)) + (require 'fg42/utils) (require 'fg42/system/core) (require 'fg42/system/utils) @@ -37,25 +37,5 @@ (funcall (fg42-system-start sys) sys))) -(comment - (macroexpand-1 '(defsystem testsystem - "docstring" - :preloads '(2 43 4) - :packages '(('elisp-extension :version "1.3.3")) - :abilities '())) - (defsystem testsystem - "docstring1" - :packages '(('elisp-extension :version "1.3.3")) - :abilities '()) - - (make-fg42-system :name "asd" :preloads '(213 452) :abilities '(x y)) - (aset testsystem 2 "sam") - (setf (fg42-system-abilities testsystem) '(3 3 3 3 3)) - (fg42-set-current-system! testsystem) - (fg42-system-preloads testsystem) - (start-system) - (fg42-system-start testsystem)) - - (provide 'fg42/system) ;;; system.el ends here diff --git a/core/fg42/utils.el b/core/fg42/utils.el index 49a4cee..ebbe37c 100644 --- a/core/fg42/utils.el +++ b/core/fg42/utils.el @@ -24,9 +24,13 @@ ;; Each system has to have a `start' function to start the setup process. ;; ;;; Code: + (require 'cl-lib) -;;; Buffer helpers ------------------------------------------------------------ +(autoload 'seq-partition "seq") +(autoload 'cl-reduce "cl-seq") + + (defun buffer-mode (buffer-or-string) "Return the major mode associated with a the given BUFFER-OR-STRING." (with-current-buffer buffer-or-string @@ -46,6 +50,11 @@ with is the buffer." (funcall fn buf))))) +(defun ->str (&rest args) + "Convert the given ARGS into string." + (funcall #'pp-to-string args)) + + (defmacro inspect-expression (&rest body) "Pretty prints the result of the given BODY." `(pp-display-expression ,@body (get-buffer-create fg42/inspect-buffer))) @@ -68,7 +77,7 @@ with is the buffer." (put-text-property 0 (length text) 'face face-symbol text)) -(defmacro comment (&rest body) +(defmacro comment (&rest _body) "A macro similar to Clojure's comment macro that ignore the BODY." (declare (indent 0)) `nil) @@ -106,9 +115,9 @@ For example: or (funcall (compose #'some-fn #'message) some-value)" (lambda (&rest values) - (reduce 'funcall (butlast fns) - :from-end t - :initial-value (apply (car (last fns)) values)))) + (cl-reduce 'funcall (butlast fns) + :from-end t + :initial-value (apply (car (last fns)) values)))) (provide 'fg42/utils) From 38809cdd1910baf05806904db2d767e275f070d7 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 16:21:55 +0100 Subject: [PATCH 06/12] [FBT]: Add fbt tool (Fg42 Build Tool) to build FG42 Signed-off-by: Sameer Rahmani --- CONTRIBUTE | 5 ++++- core/fg42/utils.el | 5 +++-- fbt | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fg42-new | 5 +++-- 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100755 fbt diff --git a/CONTRIBUTE b/CONTRIBUTE index 7977911..e7100b7 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -39,6 +39,7 @@ accept code without a proper header file. We follow these simple rules: * Make elisp linter happy +* Make byte compiler happy `make compile` * Follow functional patterns and avoid huge functions * Seperate each root level expression by two new lines (e.g function definitions) * Put `(comment ...)` expression after each macro/function to demonstrate the usage. @@ -55,7 +56,9 @@ Submit your contribution against the `master` branch. The `stable` branch is going to be our last stable version only. Please make one PR per feature. Keep your PRs as small as possible so we can review them -easily. +easily. Don't forget to make the byte compiler and the linter happy. There should not +be any build error or warning on `make compile`. We like how [Linus Torvalds thinks +about build warnings](https://linuxreviews.org/Linus_Torvalds#On_Build-Testing). Write commit messages according to adapted [this article](https://chris.beams.io/posts/git-commit/): diff --git a/core/fg42/utils.el b/core/fg42/utils.el index ebbe37c..35bce53 100644 --- a/core/fg42/utils.el +++ b/core/fg42/utils.el @@ -104,8 +104,9 @@ with is the buffer." For example for a list like (list :x 4 :y 5) we can find the value of `:x' by doing `(get-value-for lst :x)'." (let ((pairs (seq-partition lst 2))) - (when-let (pair (assq key pairs)) - (cadr pair)))) + (let ((pair (assq key pairs))) + (when pair + (cadr pair))))) (defun comp (&rest fns) diff --git a/fbt b/fbt new file mode 100755 index 0000000..c11bb53 --- /dev/null +++ b/fbt @@ -0,0 +1,53 @@ +:;exec emacs --no-site-file --no-site-lisp -batch -l "$0" -f main "$@" +;;; FGBuildTool --- The build tool for FG42 +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.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: +;;; Code: + +(defun compile (dir) + "Compile all the elisp files in the given DIR regardless of timestamp. +The DIR should be relative to FG42_HOME." + (let ((target (concat (getenv "FG42_HOME") (format "/%s" dir)))) + (message "Compiling '%s'..." target) + (add-to-list 'load-path target) + (byte-recompile-directory target 0 t))) + + +(defun build (&rest params) + "Compile the core and install the dependencies with the given PARAMS." + (compile "core")) + + +(defun main () + "Execute a subcommand by looking into input arguments of the script." + (print (version)) + (let ((command (car command-line-args-left)) + (args (cdr command-line-args-left))) + (cond + ((string= command "compile") (funcall #'compile (or (car args) "core"))) + ((string= command "build") (funcall #'build args))))) + +;; Local Variables: +;; mode: emacs-lisp +;; End: +;;; fbt ends here diff --git a/fg42-new b/fg42-new index 31a6d86..291f236 100755 --- a/fg42-new +++ b/fg42-new @@ -1,7 +1,8 @@ #! /bin/sh -export FG42_HOME=/home/lxsameer/.fg42 -FG42_WM=false /home/lxsameer/src/emacs/build/bin/emacs --name FG42 \ +export FG42_HOME="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +FG42_WM=false emacs --name FG42 \ --no-site-file --no-site-lisp --no-splash --title FG42 \ -L $FG42_HOME/core \ -L $FG42_HOME/extensions \ From c6f84490a6c92a0c4f2deb3c4965044d74021ce0 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 17:15:23 +0100 Subject: [PATCH 07/12] [FBT]: Add support for setting FG42 home and version number Signed-off-by: Sameer Rahmani --- .gitlab-ci.yml | 14 ++++++++++++++ fbt | 31 ++++++++++++++++++++++++++----- fg42-new | 2 +- scripts/compiler.el | 30 ------------------------------ 4 files changed, 41 insertions(+), 36 deletions(-) delete mode 100644 scripts/compiler.el diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e32ab6..445b456 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,20 @@ stages: script: - cd ~/.fg42/ && fg42 -nw --script build.el +.build-v3: + image: debian:stable-slim + stage: build + before_script: + - apt update && apt install -y make wget git emacs sudo + - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ && ~/.fg42/fbt build + +build-branches-v3: + extends: .build-v3 + only: + - branches + except: + - tags + build-branches: extends: .build only: diff --git a/fbt b/fbt index c11bb53..8a1ee6a 100755 --- a/fbt +++ b/fbt @@ -1,4 +1,4 @@ -:;exec emacs --no-site-file --no-site-lisp -batch -l "$0" -f main "$@" +:;exec emacs --no-site-file --no-site-lisp -batch -l "$0" -f main "$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" "$@" ;;; FGBuildTool --- The build tool for FG42 ;; ;; Copyright (c) 2010-2020 Sameer Rahmani @@ -23,6 +23,8 @@ ;; ;;; Commentary: ;;; Code: +(defvar FG42_VERSION "3.0.0-snapshot" + "The version number of the current build of FG42.") (defun compile (dir) "Compile all the elisp files in the given DIR regardless of timestamp. @@ -38,14 +40,33 @@ The DIR should be relative to FG42_HOME." (compile "core")) +(defun print-help (command) + "Print out a usage instructions and print out the invalid msg for COMMAND." + (when command + (warn "I don't know about '%s' command.\n" command)) + + (message "Usage:\n") + (message "compile [DIR] - Compiles the given DIR to bytecodes (default: \"core\")") + (message "build - Builds FG42 by compiling the code and installing dependencies.")) + + (defun main () "Execute a subcommand by looking into input arguments of the script." - (print (version)) - (let ((command (car command-line-args-left)) - (args (cdr command-line-args-left))) + (message (version)) + (message "\nFG42 Built tool v%s\n\n" FG42_VERSION) + + (let ((fg42-home (car command-line-args-left)) + (command (cadr command-line-args-left)) + (args (cddr command-line-args-left))) + + ;; FG42 Needs this env var to know where had it been installed + (setenv "FG42_HOME" fg42-home) + (setenv "FG42_VERSION" FG42_VERSION) + (cond ((string= command "compile") (funcall #'compile (or (car args) "core"))) - ((string= command "build") (funcall #'build args))))) + ((string= command "build") (funcall #'build args)) + (t (print-help command))))) ;; Local Variables: ;; mode: emacs-lisp diff --git a/fg42-new b/fg42-new index 291f236..eb9e125 100755 --- a/fg42-new +++ b/fg42-new @@ -1,6 +1,6 @@ #! /bin/sh -export FG42_HOME="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +export FG42_HOME="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" FG42_WM=false emacs --name FG42 \ --no-site-file --no-site-lisp --no-splash --title FG42 \ diff --git a/scripts/compiler.el b/scripts/compiler.el deleted file mode 100644 index 2ef295c..0000000 --- a/scripts/compiler.el +++ /dev/null @@ -1,30 +0,0 @@ -;;; FG42ByteCompiler --- The byte compiler for FG42 libraries and extensions -;; -;; Copyright (c) 2010-2020 Sameer Rahmani -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.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: -;;; Code: - -(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core")) - -(message "Compiling FG42 core...") -(byte-recompile-directory (concat (getenv "FG42_HOME") "/core") 0 t) -;;; compiler.el ends here From d6129d0eb5cf348832f3e6b71728614f3f32bf8c Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 18:37:17 +0100 Subject: [PATCH 08/12] [FBT]: Add the skeleton of the lint task --- fbt | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/fbt b/fbt index 8a1ee6a..81ff43f 100755 --- a/fbt +++ b/fbt @@ -26,10 +26,33 @@ (defvar FG42_VERSION "3.0.0-snapshot" "The version number of the current build of FG42.") +(defun ->path (dir) + "Return the absolute path to the given DIR with respect to FG42_HOME." + (concat (getenv "FG42_HOME") (format "/%s" dir))) + + +(defun el-files-in (dir) + "Return a list of elisp files in the given DIR." + (split-string (shell-command-to-string + (format "find %s -iname \"*.el\"" (->path dir))) "\n" t)) + + +(defun lint (dir) + "Run linter on all the elisp files in the given DIR." + (let ((files (el-files-in dir))) + (if files + (dolist (file files) + ;; TODO: Setup flycheck here and use it to lint the elisp file. + ;; tried to use flymake but it doesn't let you do it manually + (with-temp-buffer + (insert-file-contents file))) + (error "Couldn't find any elisp files")))) + + (defun compile (dir) "Compile all the elisp files in the given DIR regardless of timestamp. The DIR should be relative to FG42_HOME." - (let ((target (concat (getenv "FG42_HOME") (format "/%s" dir)))) + (let ((target (->path dir))) (message "Compiling '%s'..." target) (add-to-list 'load-path target) (byte-recompile-directory target 0 t))) @@ -64,6 +87,7 @@ The DIR should be relative to FG42_HOME." (setenv "FG42_VERSION" FG42_VERSION) (cond + ((string= command "lint") (funcall #'lint (or (car args) "core"))) ((string= command "compile") (funcall #'compile (or (car args) "core"))) ((string= command "build") (funcall #'build args)) (t (print-help command))))) From 3ac984953cf3d5f5e1e891915e48683fee6d8a93 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 18:42:44 +0100 Subject: [PATCH 09/12] [GitlabCI] Fix the yaml syntax error --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 445b456..613b5c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,9 @@ stages: stage: build before_script: - apt update && apt install -y make wget git emacs sudo - - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ && ~/.fg42/fbt build + - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ + script: + - ~/.fg42/fbt build build-branches-v3: extends: .build-v3 From a714e789226054b5dd2843e84ecd0603d0ecdf23 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 18:50:09 +0100 Subject: [PATCH 10/12] [System] Remove the package field. (will be added with FPKG) --- core/fg42/system/core.el | 1 - fbt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/core/fg42/system/core.el b/core/fg42/system/core.el index afcee61..a16c5ef 100644 --- a/core/fg42/system/core.el +++ b/core/fg42/system/core.el @@ -46,7 +46,6 @@ to load FG42." ;; backups, flycheck temps and stuff like that. (tmp-path "~/.tmp") - (packages '()) ;; ;; A list of preloads to setup extensions which are not loaded yet. ;; ;; For more information on preloads checkout `fg42/extension' ;; (preloads '()) diff --git a/fbt b/fbt index 81ff43f..d3171a1 100755 --- a/fbt +++ b/fbt @@ -76,7 +76,7 @@ The DIR should be relative to FG42_HOME." (defun main () "Execute a subcommand by looking into input arguments of the script." (message (version)) - (message "\nFG42 Built tool v%s\n\n" FG42_VERSION) + (message "\nFG42 Build tool v%s\n\n" FG42_VERSION) (let ((fg42-home (car command-line-args-left)) (command (cadr command-line-args-left)) From 5fc7929285398b24cc4e8c718a45be5ad0f5fa88 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 18:59:24 +0100 Subject: [PATCH 11/12] [GitlabCI] Change the way we run 'fbt build' to be relative to home --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 613b5c9..1c0e009 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ stages: - apt update && apt install -y make wget git emacs sudo - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ script: - - ~/.fg42/fbt build + - cd ~/.fg42/ && ./fbt build build-branches-v3: extends: .build-v3 From a994f0852a181380eb1e2c8bdfac0adbd2a479c9 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 19:03:46 +0100 Subject: [PATCH 12/12] [GitlabCI] Fix the branch name on the cloning process --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c0e009..2bfb9fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ stages: stage: build before_script: - apt update && apt install -y make wget git emacs sudo - - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ && cd ~/.fg42/ && make install && + - git clone -b $CI_COMMIT_REF_NAME https://gitlab.com/FG42/FG42 ~/.fg42/ && cd ~/.fg42/ && make install && script: - cd ~/.fg42/ && fg42 -nw --script build.el @@ -15,7 +15,7 @@ stages: stage: build before_script: - apt update && apt install -y make wget git emacs sudo - - git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ + - git clone -b $CI_COMMIT_REF_NAME https://gitlab.com/FG42/FG42 ~/.fg42/ script: - cd ~/.fg42/ && ./fbt build