comparison lisp/progmodes/executable.el @ 22559:d9e33b33a02f

(executable-binary-suffixes): New variable. (executable-find): Use it to look for executable program files.
author Richard M. Stallman <rms@gnu.org>
date Tue, 23 Jun 1998 18:37:01 +0000
parents 521f5765e7ce
children 39510277d6a0
comparison
equal deleted inserted replaced
22558:a342b7785783 22559:d9e33b33a02f
134 ("^\\(.+\\):\\([0-9]+\\): " 1 2)) 134 ("^\\(.+\\):\\([0-9]+\\): " 1 2))
135 "Alist of regexps used to match script errors. 135 "Alist of regexps used to match script errors.
136 See `compilation-error-regexp-alist'.") 136 See `compilation-error-regexp-alist'.")
137 137
138 ;; The C function openp slightly modified would do the trick fine 138 ;; The C function openp slightly modified would do the trick fine
139 (defvar executable-binary-suffixes
140 (if (memq system-type '(ms-dos windows-nt))
141 '(".exe" ".com" ".bat" ".cmd" ".btm" "")
142 '("")))
139 (defun executable-find (command) 143 (defun executable-find (command)
140 "Search for COMMAND in exec-path and return the absolute file name. 144 "Search for COMMAND in exec-path and return the absolute file name.
141 Return nil if COMMAND is not found anywhere in `exec-path'." 145 Return nil if COMMAND is not found anywhere in `exec-path'."
142 (let ((list exec-path) 146 (let ((list exec-path)
143 file) 147 file)
144 (while list 148 (while list
145 (setq list (if (and (setq file (expand-file-name command (car list))) 149 (setq list
146 (file-executable-p file) 150 (if (and (setq file (expand-file-name command (car list)))
147 (not (file-directory-p file))) 151 (let ((suffixes executable-binary-suffixes)
148 nil 152 candidate)
149 (setq file nil) 153 (while suffixes
150 (cdr list)))) 154 (setq candidate (concat file (car suffixes)))
155 (if (and (file-executable-p candidate)
156 (not (file-directory-p candidate)))
157 (setq suffixes nil)
158 (setq suffixes (cdr suffixes))
159 (setq candidate nil)))
160 (setq file candidate)))
161 nil
162 (setq file nil)
163 (cdr list))))
151 file)) 164 file))
152
153 165
154 (defun executable-chmod () 166 (defun executable-chmod ()
155 "This gets called after saving a file to assure that it be executable. 167 "This gets called after saving a file to assure that it be executable.
156 You can set the absolute or relative mode in variable `executable-chmod' for 168 You can set the absolute or relative mode in variable `executable-chmod' for
157 non-executable files." 169 non-executable files."