[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: Wed, 17 Apr 2002 05:28:31 -0400

> Several years ago I talked to Richard Stallman about incorporating the
> `locate-file' function in Emacs.  `locate-file' is a very useful
> XEmacs function that searches for a file in a path.

I like it.
This is obviously very convenient.  It should ideally be
implemented on top of the `openp' function, such as the
quick-hack implementation below.

How important is the MODE argument ?
I would much prefer to have a PREDICATE argument instead (easier
to implement and more flexible).  Also the current `openp' code
already checks for `file-readable-p' and `not file-directory-p'
rather than just file-readable-p.


DEFUN ("locate-file", Flocate_file, Slocate_file, 2, 4, 0,
       doc: /* Search for FILENAME through PATH.

If SUFFIXES is non-nil, it should be a list of suffixes to append to
file name when searching.

If MODE is non-nil, it should be a symbol or a list of symbols representing
requirements.  Allowed symbols are `exists', `executable', `writable', and
`readable'.  If MODE is nil, it defaults to `readable'.  */)
     (filename, path, suffixes, mode)
     Lisp_Object filename, path_list, suffixes, mode;
  Lisp_Object file;
  /* FIXME: implement the `mode' functionality.  */
  int fd = openp (path, filename, suffixes, &file, 0);
  if (fd > 0)
    close (fd);
  return file;

reply via email to

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