comparison lisp/tl/tl-misc.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents
children 4b173ad71786
comparison
equal deleted inserted replaced
3:30df88044ec6 4:b82b59fe008d
1 ;;; tl-misc.el --- miscellaneous utility of tl.
2
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version:
7 ;; $Id: tl-misc.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $
8 ;; Keywords: load-path, module, structure
9
10 ;; This file is part of tl (Tiny Library).
11
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
16
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with This program; see the file COPYING. If not, write to
24 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Code:
28
29 (require 'emu)
30 (require 'tl-str)
31
32 (autoload 'add-path "file-detect")
33 (autoload 'get-latest-path "file-detect")
34 (autoload 'file-installed-p "file-detect")
35
36
37 ;;; @ module and hook
38 ;;;
39
40 (defun call-after-loaded (module func &optional hook-name)
41 "If MODULE is provided, then FUNC is called.
42 Otherwise func is set to MODULE-load-hook.
43 If optional argument HOOK-NAME is specified,
44 it is used as hook to set. [tl-misc.el]"
45 (if (featurep module)
46 (funcall func)
47 (progn
48 (if (null hook-name)
49 (setq hook-name (symbol-concat module "-load-hook"))
50 )
51 (add-hook hook-name func)
52 )))
53
54
55 ;;; @ structure
56 ;;;
57
58 (defmacro define-structure (name &rest slots)
59 (let ((pred (symbol-concat name '-p)))
60 (cons 'progn
61 (nconc
62 (list
63 (` (defun (, pred) (obj)
64 (and (vectorp obj)
65 (eq (elt obj 0) '(, name))
66 ))
67 )
68 (` (defun (, (symbol-concat name '/create)) (, slots)
69 (, (cons 'vector (cons (list 'quote name) slots)))
70 )
71 ))
72 (let ((i 1))
73 (mapcar (function
74 (lambda (slot)
75 (prog1
76 (` (defun (, (symbol-concat name '/ slot)) (obj)
77 (if ((, pred) obj)
78 (elt obj (, i))
79 ))
80 )
81 (setq i (+ i 1))
82 )
83 )) slots)
84 )
85 (list (list 'quote name))
86 ))))
87
88
89 ;;; @ end
90 ;;;
91
92 (provide 'tl-misc)
93
94 ;;; tl-misc.el ends here