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)