[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: locate-file in Emacs
From: |
Stefan Monnier |
Subject: |
Re: locate-file in Emacs |
Date: |
Thu, 18 Apr 2002 14:59:14 -0400 |
> I don't agree with that. At least, I wouldn't obsolete them for
> XEmacs. I think they're quite useful, and much faster than the
> generic PREDICATE.
The useful part is not relevant: `executable' is not much better
than `file-executable-p' for people writing code.
Now the performance issue is something new that I haven't
thought about too much. The only case where it matters seems to be
when predicate is `file-executable-p' (since it seems to be the
only MODE in use that I can see, apart from the default).
How significant is it ? I truly do not know.
> > I have no doubt that it's been used, so do you happen to know if it
> > has been used in packages that are in active use ?
> I have no statistics about that.
Anectodes, maybe ?
When I said active use, I meant a package that can be downloaded from the
web as opposed to someone's .emacs file. Whether it's used by a million
people or just by 5 doesn't matter too much at this stage.
> > Based on the information here, I think I'll go ahead and implement
> > the functionality on top of `openp' with just a `predicate' argument
> > and without backward compatibility for `mode'.
>
> Please name your function differently to avoid confusion. I am
> beginning to regret bringing this up.
No, it would be silly not to have compatible interfaces.
[ Note that my current implementation accepts `1' as predicate to
mean file-executable-p (more or less, since it uses the `access'
syscall, so it's actually as fast as the previous code and more
importantly behaves the same). ]
> > But I have one question left: should the `file-directory-p' check be
> > enforced
> > independently from `predicate' ?
>
> Yes, please. For several days I ran my `locate-file' in place of
> XEmacs's original (to shake out the bugs), and I noticed that
> `sh-script' wouldn't load. That is because my locate-file found
> contains "packages/sh-script" (a directory) before
> "packages/sh-script/lisp/sh-script[.elc]" (a file).
I didn't mean to change the existing behavior, but I meant "when a predicate
is passed what should happen" ? In any case, it seems there is some
common agreement that directories should be ignored not matter what
the predicate says.
> > I.e. can (locate-file f p s 'file-readable-p) return a directory ?
> >
> > "Yes" is better since it allows the caller to choose whether
> > directories are considered or not but "no" is better because it
> > allows (locate-file file path suffixes 'file-executable-p) to behave
> > like your current (locate-file file path suffixes 'executable). Or
> > does the current XEmacs code always consider directories anyway ?
>
> I think it is ok for a function named `locate-file' to ignore
> directories.
That's true, but I was just thinking of the case where someone
needs to look through a path for a particular subdirectory.
Like look for the X11 subdirectory in
/usr/include:/usr/X11R6/include:/usr/local/include:/usr/share/include:...
It would be convenient to be able to use locate-file for it as well
just by passing an appropriate predicate.
Stefan
- Re: locate-file in Emacs, (continued)
- Re: locate-file in Emacs, Stefan Monnier, 2002/04/18
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/18
- Re: locate-file in Emacs, Stefan Monnier, 2002/04/18
- Re: locate-file in Emacs, Eli Zaretskii, 2002/04/18
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/18
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/18
- Re: locate-file in Emacs,
Stefan Monnier <=
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/25
- Re: locate-file in Emacs, Stefan Monnier, 2002/04/25
- Re: locate-file in Emacs, Richard Stallman, 2002/04/19
- Re: locate-file in Emacs, Miles Bader, 2002/04/18
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/18
- Re: locate-file in Emacs, Miles Bader, 2002/04/18
- Re: locate-file in Emacs, Hrvoje Niksic, 2002/04/18
- Re: locate-file in Emacs, Miles Bader, 2002/04/18