development extension added

This commit is contained in:
Sameer Rahmani 2015-07-08 21:29:42 +04:30
parent e58d80d444
commit 95d2bdfd0d
5 changed files with 80 additions and 1 deletions

View File

@ -7,4 +7,5 @@
*** TODO add support to main todo repository and collect todo form projects repositories
** TODO add startup custom buffer for kuso
** TODO add per project configuration support
** TODO configure `package-archive-priorities` so package.el install all packages from elpa first
* Release

View File

@ -2,6 +2,7 @@
(toggle-debug-on-error)
(require 'fg42)
(activate-extensions 'editor)
(activate-extensions 'editor
'development)
(fg42-initialize)

View File

@ -0,0 +1,20 @@
(require 'fpkg)
(require 'fg42/extension)
(require 'extensions/development/init)
;; Dependencies ----------------------------------
(depends-on 'flycheck)
(depends-on 'company)
(depends-on 'projectile)
(depends-on 'flyspell)
(depends-on 'diff-hl)
(depends-on 'magit)
(depends-on 'indent-guide)
(depends-on 'yasnippet)
;; Extension -------------------------------------
(extension development
:version "2.67"
:on-initialize extension/development-initialize)
(provide 'extensions/development)

View File

@ -0,0 +1,34 @@
;; Functions -------------------------------------------------
;; Quick fix for company-mode and yasnippet clashing
(defun company-yasnippet-or-completion ()
(interactive)
(if (yas/expansion-at-point)
(progn (company-abort)
(yas/expand))
(company-complete-common)))
(defun yas/expansion-at-point ()
"Tested with v0.6.1. Extracted from `yas/expand-1'"
(first (yas/current-key)))
;;;###autoload
(defun extension/development-initialize ()
"Development plugin initialization."
(message "Initializing 'development' extension.")
(ability code-completion ()
(global-company-mode t)
(define-key company-active-map "\t" 'company-yasnippet-or-completion))
(ability yas ()
(yas-global-mode 1))
(ability project-management ()
(projectile-global-mode)
(setq projectile-enable-caching t))
)
(provide 'extensions/development/init)

View File

@ -5,6 +5,9 @@
(defvar activated-extensions ()
"A list of all activated extensions.")
(defvar disabled-abilities (make-hash-table)
"A hash of all the disabled abilities")
;; Structures -----------------------------
(cl-defstruct fg42-extension
"Each FG42 extension should implement a copy of this structure."
@ -14,6 +17,26 @@
(on-initialize nil)
(on-load))
;; Functions ------------------------------
(defun active-ability? (name)
"Return t if ability was not in disabled-abilities."
(if (gethash name disabled-abilities) nil t))
(defmacro ability (name deps &rest body)
"Define an ability with the given name.
*deps* should be a list of abilities with the defined ability dependens
to them.
*body* is a block of code which will run as the ability initializer code."
`(progn
(message "00000 %s" (active-ability? (intern ,(symbol-name name))))
(if (active-ability? (intern ,(symbol-name name)))
(if (null (delq t (mapcar 'active-ability? ,deps)))
,@body))))
(defmacro extension (name &rest args)
"A simple DSL to define new fg42 extension."
`(setq ,name (apply 'make-fg42-extension :name ,(symbol-name name) (quote ,args))))