1
#| rep.io.files bootstrap
3
$Id: files.jl,v 1.4 2000/09/19 10:32:56 john Exp $
5
Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
7
This file is part of librep.
9
librep is free software; you can redistribute it and/or modify it
10
under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2, or (at your option)
14
librep is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with librep; see the file COPYING. If not, write to
21
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24
(declare (in-module rep.io.files))
26
(open-structures '(rep.lang.symbols
30
(defun file-name= (name1 name2)
31
"Returns t when NAME1 and NAME2 both name the same file."
32
(string= (canonical-file-name name1) (canonical-file-name name2)))
34
(defun file-newer-than-file-p (file1 file2)
35
"Returns t when FILE1 was modified more recently than FILE2."
36
(time-later-p (file-modtime file1) (file-modtime file2)))
38
(defun load-all (file #!optional callback)
39
"Try to load files called FILE (or FILE.jl, etc) from all directories in the
40
LISP load path (except the current directory)."
41
(let loop ((dirs load-path))
42
;; Normally the last entry in load-path is `.' We don't
43
;; want to use that. But can't just check if each item
44
;; is the current directory since sometimes rep is run
47
(when (or (cdr dirs) (not (member (car dirs) '("." ""))))
49
((full-name (expand-file-name file (car dirs))))
50
(when (or (file-exists-p full-name)
51
(file-exists-p (concat full-name ".jl"))
52
(file-exists-p (concat full-name ".jlc")))
55
(load full-name nil t)))))
58
(defun call-after-load (library thunk)
59
"Arrange for THUNK to be called immediately after the library of Lisp code
60
LIBRARY has been read by the `load' function. Note that LIBRARY must exactly
61
match the FILE argument to `load'."
62
(let ((tem (assoc library after-load-alist)))
64
(rplacd tem (cons thunk (cdr tem)))
65
(setq after-load-alist (cons (cons library (list thunk))
68
(defun eval-after-load (library form)
69
"Arrange for FORM to be evaluated immediately after the library of Lisp code
70
LIBRARY has been read by the `load' function. Note that LIBRARY must exactly
71
match the FILE argument to `load'."
72
(call-after-load library (lambda ()
73
(eval form (get-structure *user-structure*)))))
75
(export-bindings '(file-name= file-newer-than-file-p
76
load-all call-after-load eval-after-load))