diff lisp/modes/sh-script.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 4103f0995bd7
children 56c54cf7c5b6
line wrap: on
line diff
--- a/lisp/modes/sh-script.el	Mon Aug 13 08:51:05 2007 +0200
+++ b/lisp/modes/sh-script.el	Mon Aug 13 08:51:32 2007 +0200
@@ -49,6 +49,49 @@
 
 (require 'executable)
 
+;;; interpreter-mode-alist is not compatible between Emacs and XEmacs.
+;;; So fake it.
+
+(defvar sh-interpreter-mode-alist
+  '(("perl" . perl-mode)
+    ("perl5" . perl-mode)
+    ("wish" . tcl-mode)
+    ("wishx" . tcl-mode)
+    ("tcl" . tcl-mode)
+    ("tclsh" . tcl-mode)
+    ("awk" . awk-mode)
+    ("mawk" . awk-mode)
+    ("nawk" . awk-mode)
+    ("gawk" . awk-mode)
+    ("scm" . scheme-mode)
+    ("ash" . sh-mode)
+    ("bash" . sh-mode)
+    ("csh" . sh-mode)
+    ("dtksh" . sh-mode)
+    ("es" . sh-mode)
+    ("itcsh" . sh-mode)
+    ("jsh" . sh-mode)
+    ("ksh" . sh-mode)
+    ("oash" . sh-mode)
+    ("pdksh" . sh-mode)
+    ("rc" . sh-mode)
+    ("sh" . sh-mode)
+    ("sh5" . sh-mode)
+    ("tcsh" . sh-mode)
+    ("wksh" . sh-mode)
+    ("wsh" . sh-mode)
+    ("zsh" . sh-mode)
+    ("tail" . text-mode)
+    ("more" . text-mode)
+    ("less" . text-mode)
+    ("pg" . text-mode))
+  "Alist mapping interpreter names to major modes.
+This alist applies to files whose first line starts with `#!'.
+Each element looks like (INTERPRETER . MODE).
+The car of each element is compared with
+the name of the interpreter specified in the first line.
+If it matches, mode MODE is selected.")
+
 (defvar sh-mode-hook nil
   "*Hook run by `sh-mode'.")
 
@@ -339,8 +382,8 @@
   "Word to delimit here documents.")
 
 (defvar sh-test
-  '((sh "[  ]" . 3)
-    (ksh88 "[[  ]]" . 4))
+  '((sh "[  ]" . 2)
+    (ksh88 "[[  ]]" . 3))
   "Initial input in Bourne if, while and until skeletons.  See `sh-feature'.")
 
 
@@ -678,6 +721,15 @@
 ;;;###autoload
 (defalias 'shell-script-mode 'sh-mode)
 
+;;; XEmacs
+(put 'sh-mode 'font-lock-defaults
+     `((sh-font-lock-keywords
+	sh-font-lock-keywords-1
+	sh-font-lock-keywords-2)
+       ,sh-font-lock-keywords-only
+       nil
+       ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))))
+     
 
 (defun sh-font-lock-keywords (&optional keywords)
   "Function to get simple fontification based on `sh-font-lock-keywords'.
@@ -725,7 +777,8 @@
 Makes this script executable via `executable-set-magic'.
 Calls the value of `sh-set-shell-hook' if set."
   (interactive (list (completing-read "Name or path of shell: "
-				      interpreter-mode-alist
+				      ;; XEmacs change
+				      sh-interpreter-mode-alist
 				      (lambda (x) (eq (cdr x) 'sh-mode)))
 		     (eq executable-query 'function)
 		     t))
@@ -735,8 +788,10 @@
   (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg)))
   (setq require-final-newline (sh-feature sh-require-final-newline)
 ;;;	local-abbrev-table (sh-feature sh-abbrevs)
-	font-lock-keywords nil		; force resetting
-	font-lock-syntax-table nil
+	font-lock-defaults-computed nil
+	;; Next two lines kill XEmacs
+	;font-lock-keywords nil		; force resetting
+	;font-lock-syntax-table nil
 	comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*")
 	mode-line-process (format "[%s]" sh-shell)
 	sh-shell-variables nil
@@ -748,7 +803,9 @@
     (setq shell (cdr shell)))
   (and (boundp 'font-lock-mode)
        font-lock-mode
+       ;; Gnu Emacs, doesn't work
        (font-lock-mode (font-lock-mode 0)))
+       ;; (font-lock-fontify-buffer))
   (run-hooks 'sh-set-shell-hook))