[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] 21.3 executable.el - New func executable-command-find-unix-p
From: |
Jari Aalto+mail.linux |
Subject: |
[patch] 21.3 executable.el - New func executable-command-find-unix-p |
Date: |
Tue, 27 Jan 2004 15:02:06 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/20.7 (windows-nt) (i386-*-nt5.0.2195) |
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 <jari.aalto <AT> 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/
- [patch] 21.3 executable.el - New func executable-command-find-unix-p,
Jari Aalto+mail.linux <=