diff options
| author | Richard M. Stallman | 1996-11-09 22:17:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-11-09 22:17:58 +0000 |
| commit | e3dce9ba220383ad8e8a9cf033702084b7ce2045 (patch) | |
| tree | 6037e8e38f0f3ca3c580d904296e3d98874fb596 /lisp | |
| parent | 92475d89c318158aa7490fd2d017cd7fc1affed5 (diff) | |
| download | emacs-e3dce9ba220383ad8e8a9cf033702084b7ce2045.tar.gz emacs-e3dce9ba220383ad8e8a9cf033702084b7ce2045.zip | |
(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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/sh-script.el | 29 |
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." | |||
| 622 | paragraph-start (concat page-delimiter "\\|$") | 622 | paragraph-start (concat page-delimiter "\\|$") |
| 623 | paragraph-separate paragraph-start | 623 | paragraph-separate paragraph-start |
| 624 | comment-start "# " | 624 | comment-start "# " |
| 625 | comment-start-skip "#+[\t ]*" | ||
| 626 | comint-dynamic-complete-functions sh-dynamic-complete-functions | 625 | comint-dynamic-complete-functions sh-dynamic-complete-functions |
| 627 | ;; we can't look if previous line ended with `\' | 626 | ;; we can't look if previous line ended with `\' |
| 628 | comint-prompt-regexp "^[ \t]*" | 627 | comint-prompt-regexp "^[ \t]*" |
| @@ -638,13 +637,19 @@ with your script for an edit-interpret-debug cycle." | |||
| 638 | (current-column))))) | 637 | (current-column))))) |
| 639 | skeleton-filter 'sh-feature | 638 | skeleton-filter 'sh-feature |
| 640 | skeleton-newline-indent-rigidly t) | 639 | skeleton-newline-indent-rigidly t) |
| 641 | (save-excursion | 640 | ;; Parse or insert magic number for exec, and set all variables depending |
| 642 | ;; Parse or insert magic number for exec, and set all variables depending | 641 | ;; on the shell thus determined. |
| 643 | ;; on the shell thus determined. | 642 | (let ((interpreter |
| 644 | (goto-char (point-min)) | 643 | (save-excursion |
| 645 | (and (zerop (buffer-size)) | 644 | (goto-char (point-min)) |
| 646 | (not buffer-read-only) | 645 | (if (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)") |
| 647 | (sh-set-shell sh-shell-file))) | 646 | (buffer-substring (match-beginning 2) |
| 647 | (match-end 2))))) | ||
| 648 | elt) | ||
| 649 | (if interpreter | ||
| 650 | (sh-set-shell interpreter nil | ||
| 651 | (and (zerop (buffer-size)) | ||
| 652 | (not buffer-read-only))))) | ||
| 648 | (run-hooks 'sh-mode-hook)) | 653 | (run-hooks 'sh-mode-hook)) |
| 649 | ;;;###autoload | 654 | ;;;###autoload |
| 650 | (defalias 'shell-script-mode 'sh-mode) | 655 | (defalias 'shell-script-mode 'sh-mode) |
| @@ -691,7 +696,8 @@ This adds rules for comments and assignments." | |||
| 691 | 696 | ||
| 692 | (defun sh-set-shell (shell &optional no-query-flag insert-flag) | 697 | (defun sh-set-shell (shell &optional no-query-flag insert-flag) |
| 693 | "Set this buffer's shell to SHELL (a string). | 698 | "Set this buffer's shell to SHELL (a string). |
| 694 | Makes this script executable via `executable-set-magic'. | 699 | Makes this script executable via `executable-set-magic', and sets up the |
| 700 | proper starting #!-line, if INSERT-FLAG is non-nil. | ||
| 695 | Calls the value of `sh-set-shell-hook' if set." | 701 | Calls the value of `sh-set-shell-hook' if set." |
| 696 | (interactive (list (completing-read "Name or path of shell: " | 702 | (interactive (list (completing-read "Name or path of shell: " |
| 697 | interpreter-mode-alist | 703 | interpreter-mode-alist |
| @@ -701,7 +707,10 @@ Calls the value of `sh-set-shell-hook' if set." | |||
| 701 | (setq sh-shell (intern (file-name-nondirectory shell)) | 707 | (setq sh-shell (intern (file-name-nondirectory shell)) |
| 702 | sh-shell (or (cdr (assq sh-shell sh-alias-alist)) | 708 | sh-shell (or (cdr (assq sh-shell sh-alias-alist)) |
| 703 | sh-shell)) | 709 | sh-shell)) |
| 704 | (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg))) | 710 | (if insert-flag |
| 711 | (setq sh-shell-file | ||
| 712 | (executable-set-magic shell (sh-feature sh-shell-arg) | ||
| 713 | no-query-flag insert-flag))) | ||
| 705 | (setq require-final-newline (sh-feature sh-require-final-newline) | 714 | (setq require-final-newline (sh-feature sh-require-final-newline) |
| 706 | ;;; local-abbrev-table (sh-feature sh-abbrevs) | 715 | ;;; local-abbrev-table (sh-feature sh-abbrevs) |
| 707 | font-lock-keywords nil ; force resetting | 716 | font-lock-keywords nil ; force resetting |