I do JSP development using emacs and have the same needs. I using multi-mode a while
ago but found this to be a heavyweight solution. Worse, it tended to not do what I
want in terms of hiliting and indentation. (I also write a lot of JSP custom tag
code-generation templates, which hopelessly confuse matters).
Anyway, I realized all I really needed was some good syntax coloring so that I could
easily tell what is Java, what is a JSP tag, and what is HTML. In case anyone is in
the same boat, I've appended the chunk of my .emacs that does the hiliting I like.
Works for me but I'm no emacs/lisp expert; caveat emptor.
Would love to hear about any better solutions anyone has.
-p
(defvar jsp-mode-hook nil
"List of functions to call when entering jsp mode")
(autoload 'jsp-mode "cc-mode" "JSP Editing Mode" t)
(setq auto-mode-alist
(append '(("\\.jsp$" . jsp-mode)
) auto-mode-alist
)
)
(defun jsp-mode ()
"Mode which provides syntax highlighting for JSPs."
(interactive)
(kill-all-local-variables)
(setq major-mode 'jsp-mode)
(setq mode-name "jsp")
(run-hooks 'jsp-mode-hook)
(setq indent-tabs-mode nil)
(setq tab-width 2)
(hilit-set-mode-patterns
'jsp-mode
'(
("<%@.*" "%>" orange2-bold) ; JSP directives
("<%=.*" "%>" MediumBlue) ; JSP expression
(hilit-string-find ?' grey40-italic) ; double-quoted string
(hilit-string-find-singlequote ?' grey40-italic) ; single-quoted string
("<jsp:.*" "/>" orange2-bold) ; JSP tags
("<%--.*" "--%>" firebrick-italic) ; JSP comment
("<!--.*" "-->" firebrick-italic) ; HTML comment
("</\\*\\*" "\\*/" darkmagenta-italic) ; Java comments
("/\\*\\*" "\\*/" darkmagenta-italic)
("/\\*" "\\*/" firebrick-italic)
("//.*$" nil firebrick-italic)
("<[/]?[a-zA-Z]*:[a-zA-Z]" "[^%]>" orange2-bold) ; JSP custom tag
("[^_]\\<\\(request\\|response\\|pageContext\\|session\\|application\\|out\\|config\\|page\\|exception\\)\\>[^_]"
nil violetred-bold) ; JSP keywords
("<%!.*" "%>" MidnightBlue) ; JSP declaration
("<%[^!=-@].*" "%>" MediumBlue) ; JSP scriptlet
("<.*script>" "</.*script>" ForestGreen-bold) ; Javascript
("<[^%][^:]*" "[^%]>" black-bold) ; HTML tag
)
)
)
(defun hilit-string-find-singlequote (qchar)
"Bastardization of hilit-string-find from hilit19 to work for single quotes as well."
(let (st en)
(while (and (search-forward "'" nil t)
(eq qchar (char-after (1- (setq st (match-beginning 0)))))))
(while (and (search-forward "'" nil t)
(save-excursion
(setq en (point))
(forward-char -1)
(skip-chars-backward "\\\\")
(forward-char 1)
(not (zerop (% (- en (point)) 2))))))
(and en (cons st en)))
)
---
Patrick Calahan mailto:[EMAIL PROTECTED]
BEA WebLogic http://www.weblogic.com