diff --git a/lib/extensions/development/init.el b/lib/extensions/development/init.el index b7b6685..42a5d31 100644 --- a/lib/extensions/development/init.el +++ b/lib/extensions/development/init.el @@ -41,7 +41,7 @@ (ability project-config () "Makes projects configurable." - (require 'extensions/development/project-configuration)) + (require 'projects/configuration)) (ability bookmarks () (require 'bm) diff --git a/lib/extensions/development/project-configuration.el b/lib/projects/configuration.el similarity index 84% rename from lib/extensions/development/project-configuration.el rename to lib/projects/configuration.el index 5d9f010..6a1c1ef 100644 --- a/lib/extensions/development/project-configuration.el +++ b/lib/projects/configuration.el @@ -1,4 +1,4 @@ -;;; project-configurations --- A small library to load project specific configurations. +;;; configurations --- A small library to load project specific configurations. ;;; Commentary: ;;; Code: (require 'seq) @@ -6,6 +6,9 @@ (defvar project-config-dir "~/.fg42/project-config/" "This variable contains the path to the projects global configurations.") +(defvar __project-name__ nil + "It's an internal variable to holds the current project name.") + (defun project-name (project) "Return the project name of the given PROJECT." (car (last (seq-filter @@ -32,7 +35,7 @@ (defun load-config-file (project-name config) "Load the given CONFIG file with the given PROJECT-NAME." - (require 'extensions/development/project-dsl) + (require 'projects/dsl) (setq __project-name__ project-name) (load config)) @@ -47,5 +50,5 @@ (message "No configuration has been found for current project.")))) -(provide 'extensions/development/project-configuration) -;;; project-configuration.el ends here +(provide 'projects/configuration) +;;; configuration.el ends here diff --git a/lib/extensions/development/project-dsl.el b/lib/projects/dsl.el similarity index 75% rename from lib/extensions/development/project-dsl.el rename to lib/projects/dsl.el index 00d975c..526c00c 100644 --- a/lib/extensions/development/project-dsl.el +++ b/lib/projects/dsl.el @@ -1,23 +1,24 @@ -;;; project-dsl --- A dsl to be used with project configurations. +;;; dsl --- A dsl to be used with project configurations. ;;; Commentary: ;;; Code: (defvar open-project-configurations (make-hash-table :test 'equal) "This hashmap is responsible for storing project configurations.") -(defmacro on-run (body) - "It's going to run the given BODY when user wanted to run the project." +;; DSL ----------------------------------------------------- +(defmacro deftask (name body) + "Create a new task for the project with the given NAME and BODY." `(let ((pmap (gethash __project-name__ open-project-configurations (make-hash-table :test 'equal)))) - (puthash :run (lambda (buffer) ,body) pmap) + (puthash ,(symbol-name name) (lambda (buffer) ,body) pmap) (puthash __project-name__ pmap open-project-configurations))) (defmacro run-shell-command (command) "Run the given shell COMMAND on the run buffer." `(async-shell-command ,command buffer)) -;; TASK RUNNERS --------------------------------------- +;; TASK RUNNERS -------------------------------------------- (defun with-buffer (name action) "Create a buffer with the given NAME for the given ACTION." (get-buffer-create (format "*%s %s*" name action))) @@ -39,7 +40,7 @@ "Execute the :run task for the current project." (interactive) (let ((project (cdr (project-current)))) - (execute-task project :run))) + (execute-task project "run"))) -(provide 'extensions/development/project-dsl) -;;; project-dsl ends here +(provide 'projects/dsl) +;;; dsl ends here