summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-11-09 22:17:58 +0000
committerRichard M. Stallman <rms@gnu.org>1996-11-09 22:17:58 +0000
commit7d104d381d24b7ed7a6f57aeeb0734e557b634eb (patch)
tree3e8ca674171b698a3768a039fdc839c3a739d5ac
parent775dabb5ac86a8550542a49b4c2af4153c1a731e (diff)
downloademacs-7d104d381d24b7ed7a6f57aeeb0734e557b634eb.tar.gz
(sh-set-shell): Pass args no-query-flag
and insert-flag to executable-set-magic. Don't call executable-set-magic if insert-flag is nil. (sh-mode): Always call sh-set-shell, but use insert-flag arg to control whether to call executable-set-magic. No need to set comment-start-skip directly here. (sh-mode): Parse the interpreter from the file text.
-rw-r--r--lisp/progmodes/sh-script.el29
1 files changed, 19 insertions, 10 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index de456719d04..4c439e7e791 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -622,7 +622,6 @@ with your script for an edit-interpret-debug cycle."
paragraph-start (concat page-delimiter "\\|$")
paragraph-separate paragraph-start
comment-start "# "
- comment-start-skip "#+[\t ]*"
comint-dynamic-complete-functions sh-dynamic-complete-functions
;; we can't look if previous line ended with `\'
comint-prompt-regexp "^[ \t]*"
@@ -638,13 +637,19 @@ with your script for an edit-interpret-debug cycle."
(current-column)))))
skeleton-filter 'sh-feature
skeleton-newline-indent-rigidly t)
- (save-excursion
- ;; Parse or insert magic number for exec, and set all variables depending
- ;; on the shell thus determined.
- (goto-char (point-min))
- (and (zerop (buffer-size))
- (not buffer-read-only)
- (sh-set-shell sh-shell-file)))
+ ;; Parse or insert magic number for exec, and set all variables depending
+ ;; on the shell thus determined.
+ (let ((interpreter
+ (save-excursion
+ (goto-char (point-min))
+ (if (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)")
+ (buffer-substring (match-beginning 2)
+ (match-end 2)))))
+ elt)
+ (if interpreter
+ (sh-set-shell interpreter nil
+ (and (zerop (buffer-size))
+ (not buffer-read-only)))))
(run-hooks 'sh-mode-hook))
;;;###autoload
(defalias 'shell-script-mode 'sh-mode)
@@ -691,7 +696,8 @@ This adds rules for comments and assignments."
(defun sh-set-shell (shell &optional no-query-flag insert-flag)
"Set this buffer's shell to SHELL (a string).
-Makes this script executable via `executable-set-magic'.
+Makes this script executable via `executable-set-magic', and sets up the
+proper starting #!-line, if INSERT-FLAG is non-nil.
Calls the value of `sh-set-shell-hook' if set."
(interactive (list (completing-read "Name or path of shell: "
interpreter-mode-alist
@@ -701,7 +707,10 @@ Calls the value of `sh-set-shell-hook' if set."
(setq sh-shell (intern (file-name-nondirectory shell))
sh-shell (or (cdr (assq sh-shell sh-alias-alist))
sh-shell))
- (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg)))
+ (if insert-flag
+ (setq sh-shell-file
+ (executable-set-magic shell (sh-feature sh-shell-arg)
+ no-query-flag insert-flag)))
(setq require-final-newline (sh-feature sh-require-final-newline)
;;; local-abbrev-table (sh-feature sh-abbrevs)
font-lock-keywords nil ; force resetting