]> git.eshelyaron.com Git - emacs.git/commitdiff
(executable-binary-suffixes): New variable.
authorRichard M. Stallman <rms@gnu.org>
Tue, 23 Jun 1998 18:37:01 +0000 (18:37 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 23 Jun 1998 18:37:01 +0000 (18:37 +0000)
(executable-find): Use it to look for executable program files.

lisp/progmodes/executable.el

index 454090d508b7af64e72b980de07041fc2e1f045b..49028f7e7b744ca069f375bdca1f74e7c5cc0694 100644 (file)
@@ -136,21 +136,33 @@ This can be included in `font-lock-keywords' by modes that call `executable'.")
 See `compilation-error-regexp-alist'.")
 
 ;; The C function openp slightly modified would do the trick fine
+(defvar executable-binary-suffixes
+  (if (memq system-type '(ms-dos windows-nt))
+      '(".exe" ".com" ".bat" ".cmd" ".btm" "")
+    '("")))
 (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'."
   (let ((list exec-path)
        file)
     (while list
-      (setq list (if (and (setq file (expand-file-name command (car list)))
-                         (file-executable-p file)
-                         (not (file-directory-p file)))
-                    nil
-                  (setq file nil)
-                  (cdr list))))
+      (setq list
+           (if (and (setq file (expand-file-name command (car list)))
+                    (let ((suffixes executable-binary-suffixes)
+                          candidate)
+                      (while suffixes
+                        (setq candidate (concat file (car suffixes)))
+                        (if (and (file-executable-p candidate)
+                                 (not (file-directory-p candidate)))
+                            (setq suffixes nil)
+                          (setq suffixes (cdr suffixes))
+                          (setq candidate nil)))
+                      (setq file candidate)))
+               nil
+             (setq file nil)
+             (cdr list))))
     file))
 
-
 (defun executable-chmod ()
   "This gets called after saving a file to assure that it be executable.
 You can set the absolute or relative mode in variable `executable-chmod' for