;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*-
-;; Copyright (C) 1994-1996, 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2000-2016 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Keywords: languages, unix
:group 'executable)
-(defcustom executable-prefix "#! "
+(defcustom executable-prefix "#!"
"Interpreter magic number prefix inserted when there was no magic number."
+ :version "24.3" ; "#! " -> "#!"
:type 'string
:group 'executable)
(defvar executable-command nil)
(defcustom executable-self-display "tail"
- "Command you use with argument `+2' to make text files self-display.
+ "Command you use with argument `-n+2' to make text files self-display.
Note that the like of `more' doesn't work too well under Emacs \\[shell]."
:type 'string
:group 'executable)
+(make-obsolete-variable 'executable-self-display nil "25.1" 'set)
+
(defvar executable-font-lock-keywords
'(("\\`#!.*/\\([^ \t\n]+\\)" 1 font-lock-keyword-face t))
(save-window-excursion
;; Make buffer visible before question.
(switch-to-buffer (current-buffer))
- (y-or-n-p (concat "Replace magic number by `"
- executable-prefix argument "'? "))))
+ (y-or-n-p (format-message
+ "Replace magic number by `%s%s'? "
+ executable-prefix argument))))
(progn
(replace-match argument t t nil 1)
(message "Magic number changed to `%s'"
-;;;###autoload
(defun executable-self-display ()
"Turn a text file into a self-displaying Un*x command.
The magic number of such a command displays all lines but itself."
+ (declare (obsolete nil "25.1"))
(interactive)
(if (eq this-command 'executable-self-display)
(setq this-command 'executable-set-magic))
- (executable-set-magic executable-self-display "+2"))
+ (executable-set-magic executable-self-display "-n+2"))
;;;###autoload
(defun executable-make-buffer-file-executable-if-script-p ()
(save-restriction
(widen)
(string= "#!" (buffer-substring (point-min) (+ 2 (point-min)))))
- (condition-case nil
- (let* ((current-mode (file-modes (buffer-file-name)))
- (add-mode (logand ?\111 (default-file-modes))))
- (or (/= (logand ?\111 current-mode) 0)
- (zerop add-mode)
- (set-file-modes (buffer-file-name)
- (logior current-mode add-mode))))
- ;; Eg file-modes can return nil (bug#9879). It should not,
- ;; in this context, but we should handle it all the same.
- (error (message "Unable to make file executable")))))
+ ;; Eg file-modes can return nil (bug#9879). It should not,
+ ;; in this context, but we should handle it all the same.
+ (with-demoted-errors "Unable to make file executable: %s"
+ (let* ((current-mode (file-modes (buffer-file-name)))
+ (add-mode (logand ?\111 (default-file-modes))))
+ (or (/= (logand ?\111 current-mode) 0)
+ (zerop add-mode)
+ (set-file-modes (buffer-file-name)
+ (logior current-mode add-mode)))))))
(provide 'executable)