aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/executable.el
diff options
context:
space:
mode:
authorDave Love2000-06-09 09:38:58 +0000
committerDave Love2000-06-09 09:38:58 +0000
commit778e1d17edb36cc53fd7419436311f2e2bc622ff (patch)
tree5dd25bfc7779ae8fe71faa2203ad76585df4231a /lisp/progmodes/executable.el
parente1ceff3a511b77323acccb98866f709ab8e85f1f (diff)
downloademacs-778e1d17edb36cc53fd7419436311f2e2bc622ff.tar.gz
emacs-778e1d17edb36cc53fd7419436311f2e2bc622ff.zip
Byte compile dynamic.
(executable-insert): Change custom type. (executable-find): Add autoload cookie. (make-buffer-file-executable-if-script-p): New function from Noah Friedman.
Diffstat (limited to 'lisp/progmodes/executable.el')
-rw-r--r--lisp/progmodes/executable.el37
1 files changed, 29 insertions, 8 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el
index 6e999aed3b1..433ec730416 100644
--- a/lisp/progmodes/executable.el
+++ b/lisp/progmodes/executable.el
@@ -1,6 +1,6 @@
1;;; executable.el --- base functionality for executable interpreter scripts 1;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*-
2 2
3;; Copyright (C) 1994, 1995, 1996 by Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 2000 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
@@ -56,15 +56,18 @@
56 "Base functionality for executable interpreter scripts" 56 "Base functionality for executable interpreter scripts"
57 :group 'processes) 57 :group 'processes)
58 58
59(defcustom executable-insert 'other 59;; This used to default to `other', but that doesn't seem to have any
60;; significance. fx 2000-02-11.
61(defcustom executable-insert t ; 'other
60 "*Non-nil means offer to add a magic number to a file. 62 "*Non-nil means offer to add a magic number to a file.
61This takes effect when you switch to certain major modes, 63This takes effect when you switch to certain major modes,
62including Shell-script mode (`sh-mode'). 64including Shell-script mode (`sh-mode').
63When you type \\[executable-set-magic], it always offers to add or 65When you type \\[executable-set-magic], it always offers to add or
64update the magic number." 66update the magic number."
65 :type '(choice (const :tag "off" nil) 67;;; :type '(choice (const :tag "off" nil)
66 (const :tag "on" t) 68;;; (const :tag "on" t)
67 symbol) 69;;; symbol)
70 :type 'boolean
68 :group 'executable) 71 :group 'executable)
69 72
70 73
@@ -103,7 +106,7 @@ Typical values are 73 (+x) or -493 (rwxr-xr-x)."
103 106
104(defcustom executable-self-display "tail" 107(defcustom executable-self-display "tail"
105 "*Command you use with argument `+2' to make text files self-display. 108 "*Command you use with argument `+2' to make text files self-display.
106Note that the like of `more' doesn't work too well under Emacs \\[shell]." 109Note that the like of `more' doesn't work too well under Emacs \\[shell]."
107 :type 'string 110 :type 'string
108 :group 'executable) 111 :group 'executable)
109 112
@@ -139,6 +142,8 @@ See `compilation-error-regexp-alist'.")
139 (if (memq system-type '(ms-dos windows-nt)) 142 (if (memq system-type '(ms-dos windows-nt))
140 '(".exe" ".com" ".bat" ".cmd" ".btm" "") 143 '(".exe" ".com" ".bat" ".cmd" ".btm" "")
141 '(""))) 144 '("")))
145
146;;;###autoload
142(defun executable-find (command) 147(defun executable-find (command)
143 "Search for COMMAND in exec-path and return the absolute file name. 148 "Search for COMMAND in exec-path and return the absolute file name.
144Return nil if COMMAND is not found anywhere in `exec-path'." 149Return nil if COMMAND is not found anywhere in `exec-path'."
@@ -261,7 +266,23 @@ The magic number of such a command displays all lines but itself."
261 (setq this-command 'executable-set-magic)) 266 (setq this-command 'executable-set-magic))
262 (executable-set-magic executable-self-display "+2")) 267 (executable-set-magic executable-self-display "+2"))
263 268
264 269;;;###autoload
270(defun make-buffer-file-executable-if-script-p ()
271 "Make file executable according to umask if not already executable.
272If file already has any execute bits set at all, do not change existing
273file modes."
274 (and (save-excursion
275 (save-restriction
276 (widen)
277 (goto-char (point-min))
278 (save-match-data
279 (looking-at "^#!"))))
280 (let* ((current-mode (file-modes (buffer-file-name)))
281 (add-mode (logand ?\111 (default-file-modes))))
282 (or (/= (logand ?\111 current-mode) 0)
283 (zerop add-mode)
284 (set-file-modes (buffer-file-name)
285 (logior current-mode add-mode))))))
265 286
266(provide 'executable) 287(provide 'executable)
267 288