[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locate-file in Emacs

From: Eli Zaretskii
Subject: Re: locate-file in Emacs
Date: Wed, 17 Apr 2002 08:47:53 +0300

> From: Hrvoje Niksic <address@hidden>
> Date: Wed, 17 Apr 2002 07:05:26 +0200
> For example, to find an elisp file in load-path, one would use this:
>     (locate-file "simple" load-path '(".elc" ".el"))
>       => "/usr/local/lib/xemacs-21.4.6/lisp/simple.elc"
> Or, to locate a Unix executable:
>     (locate-file "ls" (split-string (getenv "PATH") path-separator)
>                  nil 'executable)
>       => "/bin/ls"
> To make the same code work under Windows:
>     (locate-file "links" (split-string (getenv "PATH") path-separator)
>                  '("" ".exe") 'executable)
>       => "/usr/bin/links"
> I find that there are many uses for this kind of lookup across a list
> of directories, and I would like to be able to use this function in
> portable elisp programs.  The XEmacs version is written in C with
> (probably) unclear copyright status, but Richard agreed to include a
> Lisp version of the function.  I came back to that yesterday and wrote
> one.
> The code follows below.  Please let me know what you think.

I'm not saying that we already have this functionality (I didn't
check that), but I thought I'd mention similar functionality:

  - executable-find in executable.el

  - find-lisp.el

  - the openp function (implemented in C) which can be used as a base
    for either a C primitive or a Lisp function (it is currently used
    by `load').

I do agree that the feature you suggest is a useful one.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]