1 ;;; initz-util.el --- Utilities.
3 ;; Copyright (C) 2002 OHASHI Akira <bg66@koka-in.org>
5 ;; Author: OHASHI Akira <bg66@koka-in.org>
6 ;; Keywords: startup, init
8 ;; This file is part of Initz.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
32 (require 'initz-globals)
33 (eval-when-compile (require 'cl))
35 (defun initz-add-to-load-list (modules)
36 "Add MODULES to `initz-load-list-internal'."
37 (let ((modules (if (listp modules) modules (list modules))))
39 (function (lambda (module)
40 (add-to-list 'initz-load-list-internal module)))
43 (defun initz-add-to-ignore-list (modules)
44 "Add MODULES to `initz-ignore-list-internal'."
45 (let ((modules (if (listp modules) modules (list modules))))
47 (function (lambda (module)
48 (add-to-list 'initz-ignore-list-internal module)))
51 (defun initz-remove-from-load-list (modules)
52 "Remove MODULES from `initz-load-list-internal'."
53 (let ((modules (if (listp modules) modules (list modules))))
55 (function (lambda (module)
56 (setq initz-load-list-internal
57 (delete module initz-load-list-internal))))
60 (defun initz-remove-from-ignore-list (modules)
61 "Remove MODULES from `initz-ignore-list-internal'."
62 (let ((modules (if (listp modules) modules (list modules))))
64 (function (lambda (module)
65 (setq initz-ignore-list-internal
66 (delete module initz-ignore-list-internal))))
69 (defun initz-set-load-list (modules)
70 "Set MODULES to `initz-load-list-internal'."
71 (let ((modules (if (listp modules) modules (list modules))))
72 (setq initz-load-list-internal modules)))
74 (defun initz-set-ignore-list (modules)
75 "Set MODULES to `initz-ignore-list-internal'."
76 (let ((modules (if (listp modules) modules (list modules))))
77 (setq initz-ignore-list-internal modules)))
79 (defun initz-add-to-load-path (paths)
80 "Add PATHS to `load-path' recursively."
81 (let ((paths (if (listp paths) paths (list paths))))
83 (function (lambda (path)
84 (when (file-directory-p path)
85 (add-to-list 'load-path path)
86 (initz-add-to-load-path
87 ;; Without `.' and `..'.
89 path t "^\\([^.].+\\|\\.[^.].+\\|\\.\\..+\\)$")))))
92 (defun initz-features ()
93 "Return the Initz features."
96 (function (lambda (feature)
97 (let ((initz-feature (initz-get-module-name
98 (concat (symbol-name feature)
100 (unless (string= initz-feature initz-null-string)
101 (intern initz-feature)))))
104 ;;; Internal functions.
105 (defun initz-get-base-name (init-file)
106 "Return base name of the INIT-FILE."
107 (file-name-sans-extension
108 (file-name-nondirectory init-file)))
110 (defun initz-get-module-name (init-file)
111 "Return module name of the INIT-FILE."
112 (let ((base-name (initz-get-base-name init-file)))
114 ((string= base-name initz-prefix) initz-prefix)
115 ((string-match (concat
116 (regexp-quote (concat initz-prefix
117 initz-separator-string))
118 "\\(" initz-module-regexp "\\)")
120 (match-string 1 base-name))
121 (t initz-null-string))))
123 (provide 'initz-util)
125 ;;; initz-util.el ends here