From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jari.aalto@poboxes.com (Jari Aalto+mail.linux) Newsgroups: gmane.emacs.bugs Subject: [patch] 21.3 executable.el - New func executable-command-find-unix-p Date: Tue, 27 Jan 2004 15:02:06 +0200 Organization: Private Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075209830 13953 80.91.224.253 (27 Jan 2004 13:23:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Jan 2004 13:23:50 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 27 14:23:42 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AlTBu-0004sq-00 for ; Tue, 27 Jan 2004 14:23:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AlT7c-0007a2-1g for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Jan 2004 08:19:16 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AlT7N-0007ZD-2v for bug-gnu-emacs@prep.ai.mit.edu; Tue, 27 Jan 2004 08:19:01 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AlT6q-0007Rq-Jb for bug-gnu-emacs@prep.ai.mit.edu; Tue, 27 Jan 2004 08:18:59 -0500 Original-Received: from [193.4.58.12] (helo=horus.isnic.is) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AlSj0-0004VE-EH for bug-gnu-emacs@prep.ai.mit.edu; Tue, 27 Jan 2004 07:53:54 -0500 Original-Received: from smtp31.kolumbus.fi (smtp31.kolumbus.fi [193.229.0.36]) by horus.isnic.is (8.12.9p2/8.12.9/isnic) with ESMTP id i0RCp8cs052646 for ; Tue, 27 Jan 2004 12:51:09 GMT (envelope-from news@phys-news1.kolumbus.fi) Original-Received: from news.kolumbus.fi (news.kolumbus.fi [193.229.0.31]) by smtp31.kolumbus.fi (8.12.10/8.12.4) with ESMTP id i0RCp51A022930 for ; Tue, 27 Jan 2004 14:51:06 +0200 (EET) Original-Received: (from news@localhost) by news.kolumbus.fi (8.11.6+Sun/8.11.6) id i0RCp5G29289 for gnu-emacs-bug@moderators.isc.org; Tue, 27 Jan 2004 14:51:05 +0200 (EET) Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: not-for-mail Original-Newsgroups: gnu.emacs.bug Original-Lines: 62 Original-NNTP-Posting-Host: a110t7.elisa.omakaista.fi Original-X-Trace: phys-news1.kolumbus.fi 1075207864 28301 81.197.3.110 (27 Jan 2004 12:51:04 GMT) Original-X-Complaints-To: abuse@kolumbus.fi Original-NNTP-Posting-Date: Tue, 27 Jan 2004 12:51:04 +0000 (UTC) User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/20.7 (windows-nt) (i386-*-nt5.0.2195) Cancel-Lock: sha1:Pnzz/upxijpfFrhnfj3LHXNdQkM= X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:6789 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:6789 I intend to fix grep-find, so we need common function to test find(1) in compile.el and filecache.el. This would also benefit igrep.el and other packages that depend on find(1). 2004-01-27 Tue Jari Aalto poboxes.com> * progmodes/executable.el (executable-command-find-unix-p): New. Check if find(1) is Unix type command. Index: executable.el =================================================================== RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/progmodes/executable.el,v retrieving revision 1.1 retrieving revision 1.2 diff -u -IId: -b -w -u -r1.1 -r1.2 --- executable.el 26 Jun 2003 18:06:37 -0000 1.1 +++ executable.el 27 Jan 2004 12:58:49 -0000 1.2 @@ -144,6 +144,31 @@ '(""))) ;;;###autoload +(defun executable-command-find-unix-p (&optional program) + "Check if command 'find' is Unix type program. +The patch to command can be assing in PROGRAM." + ;; Pick file to search from location we know + (let* ((dir (car load-path)) + (file (find-if + (lambda (x) + ;; Filter directories . and .. + (not (string-match "^\\.\\.?$" x))) + (directory-files dir)))) + (with-temp-buffer + (call-process (or program "find") + nil + (current-buffer) + nil + dir + "-name" + file + "-maxdepth" + "1") + (goto-char (point-min)) + (if (search-forward file nil t) + t)))) + +;;;###autoload (defun executable-find (command) "Search for COMMAND in exec-path and return the absolute file name. Return nil if COMMAND is not found anywhere in `exec-path'." -- http://tiny-tools.sourceforge.net/ Swatch @time http://www.mir.com.my/iTime/itime.htm http://www.ryanthiessen.com/swatch/resources.htm Use Licenses! http://www.linuxjournal.com/article.php?sid=6225 Which Licence? http://www.linuxjournal.com/article.php?sid=4825 OSI Licences http://www.opensource.org/licenses/