*** empty log message ***
[elisp/tamago.git] / egg-util.el
1 ;;; egg-util.el --- Utilities with Egg
2
3 ;; Copyright (C) 2000 ElectroTechinical Laboratory, Japan
4 ;; Copyright (C) 2000 TOMURA Satoru <tomura@etl.go.jp>
5
6 ;; Author: TOMURA Satoru <tomura@etl.go.jp>
7
8 ;; Maintainer: TOMURA Satoru <tomura@etl.go.jp>
9
10 ;; Keywords: mule, multilingual, input method
11
12 ;; This file is part of EGG.
13
14 ;; EGG is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; EGG is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
28
29 ;;; Commentary:
30
31 ;;; Code:
32
33 (provide 'egg-util)
34
35 (defun add-directory-to-load-path (dir)
36   (let ((dir (expand-file-name dir)))
37     (add-to-list 'load-path dir)
38     (let ((default-directory dir))
39       (normal-top-level-add-subdirs-to-load-path))))
40
41 (defun locate-libraries (library &optional nosuffix path interactive-call)
42   (let ((lpath (or path load-path))
43         (result nil))
44     (while lpath
45       (let ((path (locate-library library nosuffix lpath interactive-call)))
46         (if path
47             (progn
48               (setq lpath (cdr-safe 
49                            (member (directory-file-name (file-name-directory path))
50                                    lpath))
51                     result (cons path result)))
52           (progn
53             (setq lpath nil
54                   result (reverse result))))))
55     result))
56
57 (defun load-libraries (library &optional path)
58   (let ((files (locate-libraries library nil (or path load-path) nil)))
59     (while files
60       (load-file (car files))
61       (setq files (cdr files)))))
62