From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: locate-file in Emacs Date: Wed, 17 Apr 2002 05:28:31 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200204170928.g3H9SVb27019@rum.cs.yale.edu> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1019035824 29284 127.0.0.1 (17 Apr 2002 09:30:24 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 17 Apr 2002 09:30:24 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16xllg-0007cD-00 for ; Wed, 17 Apr 2002 11:30:24 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16xm4J-0005et-00 for ; Wed, 17 Apr 2002 11:49:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16xlle-0003SH-00; Wed, 17 Apr 2002 05:30:22 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16xljx-0003GA-00 for ; Wed, 17 Apr 2002 05:28:37 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g3H9SVb27019; Wed, 17 Apr 2002 05:28:31 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Hrvoje Niksic Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2693 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2693 > 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. Stefan 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; }