comparison lisp/progmodes/executable.el @ 51083:52ad052cb312

(executable-set-magic): Remove unused vars `point' and `buffer-modified-p'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 18 May 2003 21:37:23 +0000
parents 89f6eeae2af3
children 695cf19ef79e
comparison
equal deleted inserted replaced
51082:af63282f9b8e 51083:52ad052cb312
1 ;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*- 1 ;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*-
2 2
3 ;; Copyright (C) 1994, 1995, 1996, 2000 by Free Software Foundation, Inc. 3 ;; Copyright (C) 1994, 1995, 1996, 2000, 2003 by Free Software Foundation, Inc.
4 4
5 ;; Author: Daniel Pfeiffer <occitan@esperanto.org> 5 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
6 ;; Keywords: languages, unix 6 ;; Keywords: languages, unix
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
225 (string-match executable-magicless-file-regexp 225 (string-match executable-magicless-file-regexp
226 buffer-file-name)) 226 buffer-file-name))
227 (not (or insert-flag executable-insert)) 227 (not (or insert-flag executable-insert))
228 (> (point-min) 1) 228 (> (point-min) 1)
229 (save-excursion 229 (save-excursion
230 (let ((point (point-marker)) 230 (goto-char (point-min))
231 (buffer-modified-p (buffer-modified-p))) 231 (add-hook 'after-save-hook 'executable-chmod nil t)
232 (goto-char (point-min)) 232 (if (looking-at "#![ \t]*\\(.*\\)$")
233 (add-hook 'after-save-hook 'executable-chmod nil t) 233 (and (goto-char (match-beginning 1))
234 (if (looking-at "#![ \t]*\\(.*\\)$") 234 ;; If the line ends in a space,
235 (and (goto-char (match-beginning 1)) 235 ;; don't offer to change it.
236 ;; If the line ends in a space, 236 (not (= (char-after (1- (match-end 1))) ?\ ))
237 ;; don't offer to change it. 237 (not (string= argument
238 (not (= (char-after (1- (match-end 1))) ?\ )) 238 (buffer-substring (point) (match-end 1))))
239 (not (string= argument 239 (if (or (not executable-query) no-query-flag
240 (buffer-substring (point) (match-end 1)))) 240 (save-window-excursion
241 (if (or (not executable-query) no-query-flag 241 ;; Make buffer visible before question.
242 (save-window-excursion 242 (switch-to-buffer (current-buffer))
243 ;; Make buffer visible before question. 243 (y-or-n-p (concat "Replace magic number by `"
244 (switch-to-buffer (current-buffer)) 244 executable-prefix argument "'? "))))
245 (y-or-n-p (concat "Replace magic number by `" 245 (progn
246 executable-prefix argument "'? ")))) 246 (replace-match argument t t nil 1)
247 (progn 247 (message "Magic number changed to `%s'"
248 (replace-match argument t t nil 1) 248 (concat executable-prefix argument)))))
249 (message "Magic number changed to `%s'" 249 (insert executable-prefix argument ?\n)
250 (concat executable-prefix argument))))) 250 (message "Magic number changed to `%s'"
251 (insert executable-prefix argument ?\n) 251 (concat executable-prefix argument)))))
252 (message "Magic number changed to `%s'"
253 (concat executable-prefix argument)))
254 ;;; (or insert-flag
255 ;;; (eq executable-insert t)
256 ;;; (set-buffer-modified-p buffer-modified-p))
257 )))
258 interpreter) 252 interpreter)
259 253
260 254
261 255
262 ;;;###autoload 256 ;;;###autoload
274 If file already has any execute bits set at all, do not change existing 268 If file already has any execute bits set at all, do not change existing
275 file modes." 269 file modes."
276 (and (>= (buffer-size) 2) 270 (and (>= (buffer-size) 2)
277 (save-restriction 271 (save-restriction
278 (widen) 272 (widen)
279 (string= "#!" (buffer-substring 1 3))) 273 (string= "#!" (buffer-substring (point-min) (+ 2 (point-min)))))
280 (let* ((current-mode (file-modes (buffer-file-name))) 274 (let* ((current-mode (file-modes (buffer-file-name)))
281 (add-mode (logand ?\111 (default-file-modes)))) 275 (add-mode (logand ?\111 (default-file-modes))))
282 (or (/= (logand ?\111 current-mode) 0) 276 (or (/= (logand ?\111 current-mode) 0)
283 (zerop add-mode) 277 (zerop add-mode)
284 (set-file-modes (buffer-file-name) 278 (set-file-modes (buffer-file-name)