;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*-
-;; Copyright (C) 1994, 1995, 1996, 2000, 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 2000, 2003, 2004 by Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Keywords: languages, unix
;; The C function openp slightly modified would do the trick fine
(defvaralias 'executable-binary-suffixes 'exec-suffixes)
+;;;###autoload
+(defun executable-command-find-posix-p (&optional program)
+ "Check if PROGRAM handles arguments Posix-style.
+If PROGRAM is non-nil, use that instead of \"find\"."
+ ;; Pick file to search from location we know
+ (let* ((dir (file-truename data-directory))
+ (file (car (directory-files dir nil "^[^.]"))))
+ (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.
(file-modes buffer-file-name)))))))
+;;;###autoload
(defun executable-interpret (command)
"Run script with user-specified args, and collect output in a buffer.
-While script runs asynchronously, you can use the \\[next-error] command
-to find the next error."
+While script runs asynchronously, you can use the \\[next-error]
+command to find the next error. The buffer is also in `comint-mode' and
+`compilation-shell-minor-mode', so that you can answer any prompts."
(interactive (list (read-string "Run script: "
(or executable-command
buffer-file-name))))
(require 'compile)
(save-some-buffers (not compilation-ask-about-save))
- (make-local-variable 'executable-command)
- (compile-internal (setq executable-command command)
- "No more errors." "Interpretation"
- ;; Give it a simpler regexp to match.
- nil executable-error-regexp-alist))
+ (set (make-local-variable 'executable-command) command)
+ (let ((compilation-error-regexp-alist executable-error-regexp-alist))
+ (compilation-start command t (lambda (x) "*interpretation*"))))
(provide 'executable)
+;;; arch-tag: 58458d1c-d9db-45ec-942b-8bbb1d5e319d
;;; executable.el ends here