basic doc support has been added to extensions

This commit is contained in:
Sameer Rahmani 2018-03-03 23:46:10 +00:00
parent e8191bb238
commit d8bcd86f5c
5 changed files with 34 additions and 14 deletions

View File

@ -17,9 +17,12 @@
(depends-on 'yesql-ghosts)
(depends-on 'rainbow-delimiters)
(defun clojure-doc ()
"something fun")
;; Extension -------------------------------------
(extension clojure
:version "2.32"
:on-initialize extensions/clojure-initialize)
:on-initialize extensions/clojure-initialize
:docs "lib/extensions/clojure/readme.org")
(provide 'extensions/clojure)

View File

@ -3,6 +3,7 @@
(require 'extensions/editor/init)
;; Dependencies ----------------------------------
(depends-on 'adoc-mode)
(depends-on 'multiple-cursors)
(depends-on 'expand-region)
(depends-on 'seq)

View File

@ -1,6 +1,6 @@
;;; FG42 --- a simple package manager for FG42 -*- lexical-binding: t; -*-
;; Copyright (C) 2015 lxsameer
;; Copyright (C) 2010-2018 lxsameer
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; Keywords: lisp fg42 IDE package manager
@ -24,11 +24,6 @@
;; An Editor/IDE bundle base on Lovely Gnu/Emacs to make your life easier
;;; Code:
(require 'fpkg)
(require 'fg42/base)
(require 'fg42/splash)
(require 'fg42/race)
(defvar fg42-home (getenv "FG42_HOME")
"The pass to fg42-home")
@ -38,6 +33,12 @@
(defvar fg42-after-initialize-hook nil
"This hook will be called after FG42 initilization process.")
(require 'fpkg)
(require 'fg42/base)
(require 'fg42/splash)
(require 'fg42/race)
(defun fg42-initialize ()
"Initialize FG42 editor."
(run-hooks 'fg42-before-initialize-hook)

View File

@ -1,3 +1,7 @@
;;; Extebtuib --- Extension library of FG42
;;; Commentary:
;;; Code:
;; This library provides some basic means to create a new FG42 extensions
(require 'cl-lib)
@ -6,32 +10,34 @@
"A list of all activated extensions.")
(defvar disabled-abilities (make-hash-table)
"A hash of all the disabled abilities")
"A hash of all the disabled abilities.")
;; Structures -----------------------------
(cl-defstruct fg42-extension
"Each FG42 extension should implement a copy of this structure."
name
docs
(version nil)
;; Callbacks
(on-initialize nil)
(on-load))
;; Functions ------------------------------
(defun active-ability? (name)
"Return t if ability was not in disabled-abilities."
"Return t if ability with the given NAME was not in disabled-abilities."
(if (gethash name disabled-abilities) nil t))
(defun disable (&rest abilities)
"Add the given abilities to disabled-abilities hash"
"Add the given ABILITIES to disabled-abilities hash."
(dolist (abl abilities)
(puthash abl t disabled-abilities)))
;; Macros ---------------------------------
(defmacro ability (name deps &rest body)
"Define an ability with the given name.
"Define an ability with the given NAME, DEPS, and BODY.
*deps* should be a list of abilities with the defined ability dependens
to them.
@ -43,13 +49,22 @@ to them.
,@body)))
(defmacro extension (name &rest args)
"A simple DSL to define new fg42 extension."
"A simple DSL to define new fg42 extension by given NAME and ARGS."
;(declare (doc-string 1) (indent 1))
`(setq ,name (apply 'make-fg42-extension :name ,(symbol-name name) (quote ,args))))
(defmacro with-ability (name &rest body)
"Run the block of code if an ability with the given name was not disable."
"If the ability with the given NAME is not disabled, Run the BODY."
`(when (active-ability? (intern ,(symbol-name name)))
,@body))
(defun describe-extension (extension)
"Show the doc-string of the EXTENSION."
(interactive)
(let ((doc-file (fg42-extension-docs (symbol-value extension))))
(find-file (concat fg42-home "/" doc-file))
(rename-buffer (concat "*" extension " docs*"))
(read-only-mode t)))
(provide 'fg42/extension)
;;; extension ends here

View File

@ -1,4 +1,4 @@
;;; lxdrive-mode --- A minor mode for fast cursor movement
;;; Race --- A utitlity to tweak shortkeys based on user preference
;;; Commentary:
;;; Code:
(defvar user-race :god