Mercurial > hg > xemacs-beta
comparison lisp/modes/sh-script.el @ 98:0d2f883870bc r20-1b1
Import from CVS: tag r20-1b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:13:56 +0200 |
parents | 131b0175ea99 |
children | 4be1180a9e89 |
comparison
equal
deleted
inserted
replaced
97:498bf5da1c90 | 98:0d2f883870bc |
---|---|
46 ;; page 2: mode-command and utility functions | 46 ;; page 2: mode-command and utility functions |
47 ;; page 3: statement syntax-commands for various shells | 47 ;; page 3: statement syntax-commands for various shells |
48 ;; page 4: various other commands | 48 ;; page 4: various other commands |
49 | 49 |
50 (require 'executable) | 50 (require 'executable) |
51 | |
52 ;;; interpreter-mode-alist is not compatible between Emacs and XEmacs. | |
53 ;;; So fake it. | |
54 | |
55 (defvar sh-interpreter-mode-alist | |
56 '(("perl" . perl-mode) | |
57 ("perl5" . perl-mode) | |
58 ("wish" . tcl-mode) | |
59 ("wishx" . tcl-mode) | |
60 ("tcl" . tcl-mode) | |
61 ("tclsh" . tcl-mode) | |
62 ("awk" . awk-mode) | |
63 ("mawk" . awk-mode) | |
64 ("nawk" . awk-mode) | |
65 ("gawk" . awk-mode) | |
66 ("scm" . scheme-mode) | |
67 ("ash" . sh-mode) | |
68 ("bash" . sh-mode) | |
69 ("csh" . sh-mode) | |
70 ("dtksh" . sh-mode) | |
71 ("es" . sh-mode) | |
72 ("itcsh" . sh-mode) | |
73 ("jsh" . sh-mode) | |
74 ("ksh" . sh-mode) | |
75 ("oash" . sh-mode) | |
76 ("pdksh" . sh-mode) | |
77 ("rc" . sh-mode) | |
78 ("sh" . sh-mode) | |
79 ("sh5" . sh-mode) | |
80 ("tcsh" . sh-mode) | |
81 ("wksh" . sh-mode) | |
82 ("wsh" . sh-mode) | |
83 ("zsh" . sh-mode) | |
84 ("tail" . text-mode) | |
85 ("more" . text-mode) | |
86 ("less" . text-mode) | |
87 ("pg" . text-mode)) | |
88 "Alist mapping interpreter names to major modes. | |
89 This alist applies to files whose first line starts with `#!'. | |
90 Each element looks like (INTERPRETER . MODE). | |
91 The car of each element is compared with | |
92 the name of the interpreter specified in the first line. | |
93 If it matches, mode MODE is selected.") | |
51 | 94 |
52 (defvar sh-ancestor-alist | 95 (defvar sh-ancestor-alist |
53 '((ash . sh) | 96 '((ash . sh) |
54 (bash . jsh) | 97 (bash . jsh) |
55 (dtksh . ksh) | 98 (dtksh . ksh) |
670 (sh-set-shell sh-shell-file))) | 713 (sh-set-shell sh-shell-file))) |
671 (run-hooks 'sh-mode-hook)) | 714 (run-hooks 'sh-mode-hook)) |
672 ;;;###autoload | 715 ;;;###autoload |
673 (defalias 'shell-script-mode 'sh-mode) | 716 (defalias 'shell-script-mode 'sh-mode) |
674 | 717 |
718 ;;; XEmacs | |
719 (put 'sh-mode 'font-lock-defaults | |
720 `((sh-font-lock-keywords | |
721 sh-font-lock-keywords-1 | |
722 sh-font-lock-keywords-2) | |
723 ,sh-font-lock-keywords-only | |
724 nil | |
725 ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")))) | |
726 | |
675 | 727 |
676 (defun sh-font-lock-keywords (&optional keywords) | 728 (defun sh-font-lock-keywords (&optional keywords) |
677 "Function to get simple fontification based on `sh-font-lock-keywords'. | 729 "Function to get simple fontification based on `sh-font-lock-keywords'. |
678 This adds rules for comments and assignments." | 730 This adds rules for comments and assignments." |
679 (sh-feature sh-font-lock-keywords | 731 (sh-feature sh-font-lock-keywords |
717 (defun sh-set-shell (shell &optional no-query-flag insert-flag) | 769 (defun sh-set-shell (shell &optional no-query-flag insert-flag) |
718 "Set this buffer's shell to SHELL (a string). | 770 "Set this buffer's shell to SHELL (a string). |
719 Makes this script executable via `executable-set-magic'. | 771 Makes this script executable via `executable-set-magic'. |
720 Calls the value of `sh-set-shell-hook' if set." | 772 Calls the value of `sh-set-shell-hook' if set." |
721 (interactive (list (completing-read "Name or path of shell: " | 773 (interactive (list (completing-read "Name or path of shell: " |
722 interpreter-mode-alist | 774 ;; XEmacs change |
775 sh-interpreter-mode-alist | |
723 (lambda (x) (eq (cdr x) 'sh-mode))) | 776 (lambda (x) (eq (cdr x) 'sh-mode))) |
724 (eq executable-query 'function) | 777 (eq executable-query 'function) |
725 t)) | 778 t)) |
726 (setq sh-shell (intern (file-name-nondirectory shell)) | 779 (setq sh-shell (intern (file-name-nondirectory shell)) |
727 sh-shell (or (cdr (assq sh-shell sh-alias-alist)) | 780 sh-shell (or (cdr (assq sh-shell sh-alias-alist)) |
728 sh-shell)) | 781 sh-shell)) |
729 (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg))) | 782 (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg))) |
730 (setq require-final-newline (sh-feature sh-require-final-newline) | 783 (setq require-final-newline (sh-feature sh-require-final-newline) |
731 ;;; local-abbrev-table (sh-feature sh-abbrevs) | 784 ;;; local-abbrev-table (sh-feature sh-abbrevs) |
732 font-lock-keywords nil ; force resetting | 785 font-lock-defaults-computed nil |
733 font-lock-syntax-table nil | 786 ;; Next two lines kill XEmacs |
787 ;font-lock-keywords nil ; force resetting | |
788 ;font-lock-syntax-table nil | |
734 comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") | 789 comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") |
735 mode-line-process (format "[%s]" sh-shell) | 790 mode-line-process (format "[%s]" sh-shell) |
736 sh-shell-variables nil | 791 sh-shell-variables nil |
737 sh-shell-variables-initialized nil | 792 sh-shell-variables-initialized nil |
738 shell (sh-feature sh-variables)) | 793 shell (sh-feature sh-variables)) |
740 (while shell | 795 (while shell |
741 (sh-remember-variable (car shell)) | 796 (sh-remember-variable (car shell)) |
742 (setq shell (cdr shell))) | 797 (setq shell (cdr shell))) |
743 (and (boundp 'font-lock-mode) | 798 (and (boundp 'font-lock-mode) |
744 font-lock-mode | 799 font-lock-mode |
800 ;; Gnu Emacs, doesn't work | |
745 (font-lock-mode (font-lock-mode 0))) | 801 (font-lock-mode (font-lock-mode 0))) |
802 ;; (font-lock-fontify-buffer)) | |
746 (run-hooks 'sh-set-shell-hook)) | 803 (run-hooks 'sh-set-shell-hook)) |
747 | 804 |
748 | 805 |
749 | 806 |
750 (defun sh-feature (list &optional function) | 807 (defun sh-feature (list &optional function) |