Project DSL related files moved to their own namespace

This commit is contained in:
Sameer Rahmani 2018-03-21 20:59:39 +00:00
parent 5f82e9340c
commit 274b064225
3 changed files with 17 additions and 13 deletions

View File

@ -41,7 +41,7 @@
(ability project-config ()
"Makes projects configurable."
(require 'extensions/development/project-configuration))
(require 'projects/configuration))
(ability bookmarks ()
(require 'bm)

View File

@ -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

View File

@ -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