Re: locate-file in Emacs

From:

Stefan Monnier

Subject:

Re: locate-file in Emacs

Date:

Thu, 18 Apr 2002 10:08:03 -0400

> "Stefan Monnier" <monnier+gnu/address@hidden> writes:
>
> >> PREDICATE might make sense, but I don't remember needing it in
> >> practice. Plus, it'd change the interface and hence undermine the
> >> whole point of sharing the function.
> >
> > Well, I was wondering if it was possible to get XEmacs to adopt it
> > as well ;-)
>
> That would break backward compatibility, which is fairly important in
I fail to see why:
(defun locate-file (f p s predicate)
(cond
((memq predicate '(executable writable ...)) ...)
((functionp predicate) nil)
((listp predicate) ...)
...)
you should be able to keep backward compatibility just fine.
The qusetion is whether or not you find the `predicate' interface
preferable. I do because it's more flexible.
But I'm biased since it also makes our implementation simpler.
Of course, otherwise we can export the `openp' function "raw"
(but adding a `predicate' argument) and then implement locate-file's
MODE argument in elisp on top of it.
I think there's no question that locate-file should exist in Emacs
and I thank you for pushing us to implement it.
Stefan
PS: a grep through XEmacs packages seems to indicate that the MODE argument
is rarely used and that the few times it's used it's only to check
executablility but uses the integer 1 instead of the `executable'
symbol. So assuming that the core code is updated to the new interface,
I'm not even sure if `executable', `writable' and friends needs to
be supported (although the integer 1 should be).
Unless of course I missed something.