comparison lisp/progmodes/executable.el @ 39933:89f6eeae2af3

(executable-binary-suffixes): Make varalias. (executable-find): Use exec-suffixes. (executable-set-magic): Don't use make-local-hook.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 14 Oct 2001 20:09:46 +0000
parents 0e498f6c5404
children 52ad052cb312 d7ddb3e565de
comparison
equal deleted inserted replaced
39932:ade54d52bb06 39933:89f6eeae2af3
136 ("^\\(.+\\):\\([0-9]+\\): " 1 2)) 136 ("^\\(.+\\):\\([0-9]+\\): " 1 2))
137 "Alist of regexps used to match script errors. 137 "Alist of regexps used to match script errors.
138 See `compilation-error-regexp-alist'.") 138 See `compilation-error-regexp-alist'.")
139 139
140 ;; The C function openp slightly modified would do the trick fine 140 ;; The C function openp slightly modified would do the trick fine
141 (defvar executable-binary-suffixes 141 (defvaralias 'executable-binary-suffixes 'exec-suffixes)
142 (if (memq system-type '(ms-dos windows-nt))
143 '(".exe" ".com" ".bat" ".cmd" ".btm" "")
144 '("")))
145 142
146 ;;;###autoload 143 ;;;###autoload
147 (defun executable-find (command) 144 (defun executable-find (command)
148 "Search for COMMAND in exec-path and return the absolute file name. 145 "Search for COMMAND in `exec-path' and return the absolute file name.
149 Return nil if COMMAND is not found anywhere in `exec-path'." 146 Return nil if COMMAND is not found anywhere in `exec-path'."
150 (let ((list exec-path) 147 (let ((list exec-path)
151 file) 148 file)
152 (while list 149 (while list
153 (setq list 150 (setq list
154 (if (and (setq file (expand-file-name command (car list))) 151 (if (and (setq file (expand-file-name command (car list)))
155 (let ((suffixes executable-binary-suffixes) 152 (let ((suffixes exec-suffixes)
156 candidate) 153 candidate)
157 (while suffixes 154 (while suffixes
158 (setq candidate (concat file (car suffixes))) 155 (setq candidate (concat file (car suffixes)))
159 (if (and (file-executable-p candidate) 156 (if (and (file-executable-p candidate)
160 (not (file-directory-p candidate))) 157 (not (file-directory-p candidate)))
231 (> (point-min) 1) 228 (> (point-min) 1)
232 (save-excursion 229 (save-excursion
233 (let ((point (point-marker)) 230 (let ((point (point-marker))
234 (buffer-modified-p (buffer-modified-p))) 231 (buffer-modified-p (buffer-modified-p)))
235 (goto-char (point-min)) 232 (goto-char (point-min))
236 (make-local-hook 'after-save-hook)
237 (add-hook 'after-save-hook 'executable-chmod nil t) 233 (add-hook 'after-save-hook 'executable-chmod nil t)
238 (if (looking-at "#![ \t]*\\(.*\\)$") 234 (if (looking-at "#![ \t]*\\(.*\\)$")
239 (and (goto-char (match-beginning 1)) 235 (and (goto-char (match-beginning 1))
240 ;; If the line ends in a space, 236 ;; If the line ends in a space,
241 ;; don't offer to change it. 237 ;; don't offer to change it.