Path: utzoo!attcan!uunet!littlei!intelisc!omepd!merlyn From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.emacs Subject: Re: Is a file loadable? Message-ID: <3779@omepd> Date: 2 Sep 88 16:30:24 GMT References: <5852@columbia.edu> <36722@yale-celray.yale.UUCP> <1140@titan.SW.MCC.COM> Sender: news@omepd Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 36 In-reply-to: janssen@titan.sw.mcc.com (Bill Janssen) In article <1140@titan.SW.MCC.COM>, janssen@titan (Bill Janssen) writes: | [some nice lisp code] Here's one that's a little shorter (and probably more robust) that I wrote after seeing Bill's code. Purists will want to change the "'(lambda ...)"s to "(function (lambda ...))"s, but I'm not compiling this one yet. Note that this one properly handles the "nil" in the load-path, and the NOSUFFIX flag of load. (defun which-load (file &optional nosuffix) "Find out which FILE would be loaded with the current `load-path'. Return a string representing the absolute path-name of the file that would be loaded with a `load' command, or nil if no such file exists. If optional NOSUFFIX is non-nil, don't try adding suffixes .elc or .el to the specified name FILE (ala `load'). This function cannot test the contents of the file for appropriateness to be loaded, but neither does `load'." (catch 'answer (mapcar '(lambda (dir) (mapcar '(lambda (suf) (let ((try (expand-file-name (concat file suf) dir))) (and (file-readable-p try) (null (file-directory-p try)) (throw 'answer try)))) (if nosuffix '("") '(".elc" ".el" "")))) load-path) nil)) Yours for a better tomorrow, -- Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 on contract to BiiN Technical Publications (for now :-), Hillsboro, Oregon or ...!tektronix!inteloa[!intelob]!merlyn Standard disclaimer: I *am* my employer!