1
;;; -*- Mode: Emacs-Lisp; -*-
2
3
;;;;;;; Activator: an init.d style config manager
4
;; 
5
;; This file is NOT part of GNU Emacs
6
;;
7
;; Copyright (c) 2009, Andrew Gwozdziewycz <web@apgwoz.com>
8
;;
9
;; This is free software; you can redistribute it and/or modify it under the
10
;; terms of the GNU General Public License as published by the Free Software
11
;; Foundation; either version 2, or (at your option) any later version. This is
12
;; distributed in the hope that it will be useful, but without any warranty;
13
;; without even the implied warranty of merchantability or fitness for a
14
;; particular purpose.  See the GNU General Public License for more details. You
15
;; should have received a copy of the GNU General Public License along with 
16
;; Emacs; see the file `COPYING'. If not, write to the Free Software 
17
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18
19
20
;; INTRODUCTION:
21
;; 
22
;;   Activator adds an init.d style loader for configuration files in GNU Emacs
23
;;
24
;; COMPATIBILITY:
25
;; 
26
;;   GNU Emacs 22 -- Only tested version. 
27
;;   Other versions -- There's no reason it wouldn't work...
28
;;
29
;; INSTALLATION:
30
;; 
31
;;   To install, put this file, `activator.el', somewhere in your `load-path' 
32
;;   and add the following lines to your `.emacs' file:
33
;;     
34
;;       (require 'activator)
35
;;       (activator-start)
36
;; 
37
;;   If you don't know what your load path is....
38
;;
39
;; HOW TO USE:
40
;; 
41
;;   One installed, the best way is to create a directory to add your config 
42
;;   files to. For example, on my machines, I use `~/.emacs.d/activator.d'. This
43
;;   is the default file path for where your configuration files will be loaded
44
;;   from.
45
;;   
46
;;   To change this path, set the variable `activator-load-path' to your desired
47
;;   path like so:
48
;;
49
;;      (setq activator-load-path "~/path/to/activator/config/files")
50
;;
51
;;   Activator supports the ability to override the filename format for the 
52
;;   files that will be loaded from the filepath. By default this value is set
53
;;   to include files of the form `00something.el', where `00' represents the
54
;;   order in which to include the file. 
55
;;  
56
;;   You can change this by setting the variable `activator-filename-pattern' to
57
;;   your desired pattern like so:
58
;;
59
;;      (setq activator-filename-pattern "^\[0-9\]\[0-9\].*\.el$")
60
;;
61
;; 
62
63
64
(defconst activator-copyright "Copyright (C) 2009 Andrew Gwozdziewycz")
65
(defconst activator-version 0.01)
66
(defconst activator-author-name "Andrew Gwozdziewycz")
67
(defconst activator-author-email "web@apgwoz.com")
68
(defconst activator-web-page "http://www.apgwoz.com/activator/")
69
(defconst activator-license "GNU General Public License")
70
71
(defgroup activator nil
72
  "Activator is used for creating an organized startup for emacs"
73
  :prefix "activator-"
74
  :link '(url-link "http://www.apgwoz.com/"))
75
76
(defcustom activator-load-path "~/.emacs.d/activator.d/"
77
  "Load path for the files you want to include when activator is started"
78
  :group 'activator
79
  :type 'string)
80
81
(defcustom activator-filename-pattern "^\[0-9\]\[0-9\].*\.el$"
82
  "Regular Expression specifying what activator file names should look like."
83
  :group 'activator
84
  :type 'string)
85
86
(defun activator-get-files (&optional path pattern)
87
  "Gets files from path specified by `activator-load-path', or from the 
88
optional path"
89
  (let ((path (or path activator-load-path))
90
        (pattern (or pattern activator-filename-pattern)))
91
    (message path)
92
    (message pattern)
93
    (directory-files path t pattern)))
94
95
(defun activator-load-file (file)
96
  (load-file file))
97
98
(defun activator-start ()
99
  "Starts activator, thereby running all the files in `activator-load-path' that
100
match the `activator-filename-pattern`"
101
  (interactive)
102
  (if (not (boundp 'activator-load-path))
103
      (error "Please set `activator-load-path`")
104
    (mapcar 'activator-load-file (activator-get-files))))
105
106
(provide 'activator)