>>>> "Andy" == Andy Piper
<andyp(a)parallax.co.uk> writes:
Andy> I get fon't lock errors when editing shell scripts - does anyone else
see
Andy> this?
Andy> andy
Hello Andy,
I have this in my site-start.el which might be worth trying:
(setq interpreter-mode-alist
(cons '("^#!.*/csh\\b" . csh-sh-mode) interpreter-mode-alist))
(setq interpreter-mode-alist
(cons '("^#!.*/ksh\\b" . ksh-sh-mode) interpreter-mode-alist))
(setq interpreter-mode-alist
(cons '("^#!.*/sh\\b" . sh-sh-mode) interpreter-mode-alist))
(setq auto-mode-alist
(append '(("\\.C$" . c++-mode)
("\\.cc$" . c++-mode)
("\\.hh$" . c++-mode)
("\\.t$" . c++-mode)
("\\.c$" . c-mode)
("\\.h$" . c++-mode)
("\\.s$" . asm-mode)
("\\.n?awk$" . awk-mode)
;;; It's not the extension, it's the magic number that counts!
;;; Ideally they agree.
("\\.csh$" . csh-sh-mode)
("\\.ksh$" . ksh-sh-mode)
("\\.sh$" . sh-sh-mode)
; <lines deleted by Adrian>
)
auto-mode-alist))
; <lines deleted by Adrian>
(defun csh-sh-mode ()
(add-hook 'sh-mode-hook
'(lambda ()
(sh-set-shell "/bin/csh")))
(sh-mode))
(defun ksh-sh-mode ()
(add-hook 'sh-mode-hook
'(lambda ()
(sh-set-shell "/bin/ksh")))
(sh-mode))
(defun sh-sh-mode ()
(add-hook 'sh-mode-hook
'(lambda ()
(sh-set-shell "/bin/sh")))
(sh-mode))
(autoload 'sh-mode "sh-script" "Major mode for editing shell
scripts.")
;; Begin of fixes for sh-script by Martin Buchholz
(require 'sh-script)
(setq sh-font-lock-keywords-only nil)
(defun sh-font-lock-keywords (&optional keywords)
"Function to get simple fontification based on `sh-font-lock-keywords'.
This adds rules for comments and assignments."
(sh-feature sh-font-lock-keywords
(lambda (list)
`((,(sh-feature sh-assignment-regexp)
1 font-lock-variable-name-face)
,@keywords
,@list))))
(add-hook 'sh-mode-hook 'my-sh-mode-syntax-table)
(defun my-sh-mode-syntax-table ()
(set-syntax-table (make-syntax-table (standard-syntax-table)))
(modify-syntax-entry ?\# "<")
(modify-syntax-entry ?\n ">")
(modify-syntax-entry ?\" "\"")
(modify-syntax-entry ?\' "\"")
(modify-syntax-entry ?\` "$")
(modify-syntax-entry ?_ "_")
(modify-syntax-entry ?$ "_"))
;; End of fixes for sh-script by Martin Buchholz
;; The following hook is for `shell' and `shell-mode' defined in
;; `comint/shell.el' implementing a mode for interactive shells.
;; (add-hook 'shell-mode-hook 'install-shell-fonts)
;; This just doesn't work right: Has no notion of shell-input[-face].
;; Cannot co-exist with above shell-mode-hook 'install-shell-fonts.
(add-hook 'shell-mode-hook 'turn-on-font-lock)
(setq shell-prompt-pattern (purecopy "^[^#$%>)\n]*[#$%>)] $"))
Good Luck,
Adrian
--
Adrian Aichner
Applications Engineer
Teradyne GmbH
Semiconductor Test Group Telephone +49/89/41861(0)-208
Dingolfinger Straße 2 Fax +49/89/41861-217
D-81673 MÜNCHEN E-mail aichner(a)ecf.teradyne.com