diff options
| author | Richard M. Stallman | 1998-06-23 18:37:01 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-06-23 18:37:01 +0000 |
| commit | 80e1568a890cc563649ed8766b4f85163b0ff33c (patch) | |
| tree | 11ba49598a6b0a3128db910fe60a84e2e4f30569 /lisp/progmodes/executable.el | |
| parent | 86e0d95639ab4e6a76b4c1b766d6598cff4a6609 (diff) | |
| download | emacs-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.el | 26 |
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'.") | |||
| 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 | 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. |
| 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 |