emacs-devel
[Top][All Lists]
Advanced

[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 11:27:15 -0400

> >> 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 ...)) ...)
> 
> That's fine; I thought you wanted to disallow old-style MODE in favor
> of PREDICATE which you found easier to implement.

No, I'm quite aware of the fact that breaking backward compatibility
is not done so lightly ;-).

> > you should be able to keep backward compatibility just fine.
> > The question is whether or not you find the `predicate' interface
> > preferable.
> 
> I find this "mixing" of interfaces far from elegant, but I'll agree
> that it's flexible.

I'd of course document the MODE-style arguments as obsolete, so
that the inelegance is "temporary".

> > 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.
> 
> That's the old interface, which XEmacs still supports.  In it the MODE
> was a number equivalent to what access() accepts as the second arg,
> and the SUFFIXES were one colon-separated string.

That's what I figured.

> >     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
> 
> Then you don't care about the compatibility with the existing XEmacs
> interface.  I can understand that, because you don't have to support
> its uses; but I do.  If it means something to you as a "proof", I've
> used it in my programs.

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 ?

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'.

But I have one question left: should the `file-directory-p' check be enforced
independently from `predicate' ?
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 ?


        Stefan




reply via email to

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