comparison lisp/tl/file-detect.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 360340f9fd5f
children
comparison
equal deleted inserted replaced
109:e183fc049578 110:fe104dbd9147
2 2
3 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
4 4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> 5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: 6 ;; Version:
7 ;; $Id: file-detect.el,v 1.4 1997/03/08 23:26:56 steve Exp $ 7 ;; $Id: file-detect.el,v 1.5 1997/03/16 03:05:44 steve Exp $
8 ;; Keywords: install, module 8 ;; Keywords: install, module
9 9
10 ;; This file is part of tl (Tiny Library). 10 ;; This file is part of tl (Tiny Library).
11 11
12 ;; This program is free software; you can redistribute it and/or 12 ;; This program is free software; you can redistribute it and/or
115 (throw 'tag path) 115 (throw 'tag path)
116 ) 116 )
117 (setq paths (cdr paths)) 117 (setq paths (cdr paths))
118 )))) 118 ))))
119 119
120 (defvar exec-suffix-list '("")
121 "*List of suffixes for executable.")
122
123 (defun exec-installed-p (file &optional paths suffixes)
124 "Return absolute-path of FILE if FILE exists in PATHS.
125 If PATHS is omitted, `exec-path' is used.
126 If suffixes is omitted, `exec-suffix-list' is used. [file-detect.el]"
127 (or paths
128 (setq paths exec-path)
129 )
130 (or suffixes
131 (setq suffixes exec-suffix-list)
132 )
133 (catch 'tag
134 (while paths
135 (let ((stem (expand-file-name file (car paths)))
136 (sufs suffixes)
137 )
138 (while sufs
139 (let ((file (concat stem (car sufs))))
140 (if (file-exists-p file)
141 (throw 'tag file)
142 ))
143 (setq sufs (cdr sufs))
144 ))
145 (setq paths (cdr paths))
146 )))
147
120 (defun module-installed-p (module &optional paths) 148 (defun module-installed-p (module &optional paths)
121 "Return t if module is provided or exists in PATHS. 149 "Return t if module is provided or exists in PATHS.
122 If PATHS is omitted, `load-path' is used. [file-detect.el]" 150 If PATHS is omitted, `load-path' is used. [file-detect.el]"
123 (or (featurep module) 151 (or (featurep module)
124 (let ((name (symbol-name module))) 152 (exec-installed-p (symbol-name module) load-path '(".elc" ".el"))
125 (if (null paths) 153 ))
126 (setq paths load-path)
127 )
128 (catch 'tag
129 (while paths
130 (let ((file (expand-file-name name (car paths))))
131 (let ((elc-file (concat file ".elc")))
132 (if (file-exists-p elc-file)
133 (throw 'tag elc-file)
134 ))
135 (let ((el-file (concat file ".el")))
136 (if (file-exists-p el-file)
137 (throw 'tag el-file)
138 ))
139 (if (file-exists-p file)
140 (throw 'tag file)
141 )
142 )
143 (setq paths (cdr paths))
144 )))))
145 154
146 155
147 ;;; @ end 156 ;;; @ end
148 ;;; 157 ;;;
149 158