project configuration loader has been added

This commit is contained in:
Sameer Rahmani 2018-03-19 15:11:59 +00:00
parent 978485ad8e
commit a6d657e2f4
3 changed files with 64 additions and 0 deletions

View File

@ -39,6 +39,10 @@
"Development plugin initialization."
(message "Initializing 'development' extension.")
(ability project-config ()
"Makes projects configurable."
(require 'extensions/development/project-configuration))
(ability bookmarks ()
(require 'bm)

View File

@ -0,0 +1,53 @@
;;; project-configurations --- A small library to load project specific configurations.
;;; Commentary:
;;; Code:
(require 'seq)
(defvar open-project-configurations (make-hash-table)
"This hashmap is responsible for storing project configurations.")
(defvar project-config-dir "~/.fg42/project-config/"
"This variable contains the path to the projects global configurations.")
(defun project-name (project)
"Return the project name of the given PROJECT."
(car (last (seq-filter
(lambda (x) (not (equal "" x)))
(split-string project "/")))))
(defun global-project-config-path (project)
"Return path of the global project config for the given PROJECT or nil."
(let ((config-path (format "%s/%s.el"
project-config-dir
(project-name project))))
(if (file-exists-p config-path)
config-path
nil)))
(defun config-path (project)
"Return the path of the given PROJECT configuration."
(let ((in-proj-config (format "%s.fg42.el" project))
(global-proj-config (global-project-config-path project)))
(if (file-exists-p in-proj-config)
in-proj-config
global-proj-config)))
(defun load-config-file (config)
"Load the given CONFIG file."
(require 'extensions/development/project-dsl)
(load config))
(defun load-configuration ()
"Load the configuration for the current project."
(interactive)
(let* ((project (cdr (project-current)))
(config (config-path project)))
(if (not (equal nil config))
(load-config-file config)
(message "No configuration has been found for current project."))))
(provide 'extensions/development/project-configuration)
;;; project-configuration.el ends here

View File

@ -0,0 +1,7 @@
;;; project-dsl --- A dsl to be used with project configurations.
;;; Commentary:
;;; Code:
(provide 'extensions/development/project-dsl)
;;; project-dsl ends here