aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/executable.el
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-23 18:37:01 +0000
committerRichard M. Stallman1998-06-23 18:37:01 +0000
commit80e1568a890cc563649ed8766b4f85163b0ff33c (patch)
tree11ba49598a6b0a3128db910fe60a84e2e4f30569 /lisp/progmodes/executable.el
parent86e0d95639ab4e6a76b4c1b766d6598cff4a6609 (diff)
downloademacs-80e1568a890cc563649ed8766b4f85163b0ff33c.tar.gz
emacs-80e1568a890cc563649ed8766b4f85163b0ff33c.zip
(executable-binary-suffixes): New variable.
(executable-find): Use it to look for executable program files.
Diffstat (limited to 'lisp/progmodes/executable.el')
-rw-r--r--lisp/progmodes/executable.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el
index 454090d508b..49028f7e7b7 100644
--- a/lisp/progmodes/executable.el
+++ b/lisp/progmodes/executable.el
@@ -136,21 +136,33 @@ This can be included in `font-lock-keywords' by modes that call `executable'.")
136See `compilation-error-regexp-alist'.") 136See `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.
141Return nil if COMMAND is not found anywhere in `exec-path'." 145Return 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 165
153
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.
156You can set the absolute or relative mode in variable `executable-chmod' for 168You can set the absolute or relative mode in variable `executable-chmod' for