home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help,gnu.emacs.src
- Path: sparky!uunet!stanford.edu!ames!haven.umd.edu!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!zrz.tu-berlin.de!mailgzrz.tu-berlin.de!nickel
- From: nickel@cs.tu-berlin.de (Juergen Nickelsen)
- Subject: Re: M-x which
- In-Reply-To: guttman@circe.mitre.org's message of Sat, 5 Sep 1992 18:21:27 GMT
- Message-ID: <NICKEL.92Sep6193533@desaster.cs.tu-berlin.de>
- Lines: 44
- Sender: news@mailgzrz.tu-berlin.de (News Manager)
- Nntp-Posting-Host: desaster.cs.tu-berlin.de
- Reply-To: nickel@cs.tu-berlin.de
- Organization: STONE Project, Technical University of Berlin, Germany
- References: <GUTTMAN.92Sep5132127@circe.mitre.org>
- Date: Sun, 6 Sep 1992 17:35:35 GMT
-
- In article <GUTTMAN.92Sep5132127@circe.mitre.org>
- guttman@circe.mitre.org (Joshua D. Guttman) writes:
-
- > Does someone have a "M-x which" command?
- >
- > What I mean is a command that will prompt for a string; it then gives as a
- > message the pathname of the file that would have been loaded, had "M-x load"
- > been given the same string. You know, it would just emulate the search down
- > load-path.
-
- Yes. This function returns a list of the locations in load-path where
- the file has been found. The file to be loaded is the first of the
- list (car found-list).
-
- (defun which-load-file (file &optional nosuffix)
- "Determines from where FILE is loaded.
- Returned is a list of pathnames or nil if FILE can't be found in
- load-path. If optional second arg NOSUFFIX is non-nil, don't try
- adding suffixes .elc or .el to the specified name FILE."
- (interactive "sFile: \nP")
- (let ((found-list nil)
- (files (list (concat file ".elc") (concat file ".el") file))
- (search-list load-path))
- (while search-list
- (let ((file-list files))
- (while file-list
- (let ((actual-path (concat (car search-list)
- (if (string-match "/$" (car search-list))
- ""
- "/")
- (car file-list))))
- (if (and (file-exists-p actual-path)
- (not (file-directory-p actual-path)))
- (setq found-list (cons actual-path found-list))))
- (setq file-list (cdr file-list))))
- (setq search-list (cdr search-list)))
- (setq found-list (reverse found-list))
- (if (interactive-p)
- (if found-list
- (message "%s" found-list)
- (message "%s not found" file))
- found-list)))
- --
- Juergen Nickelsen
-