Define own jsp-mode based on html-mode with JSP comment style.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 02 Nov 2012 12:09:02 +0200
changeset 985 ad3c49e55848
parent 984 3dea749e5fe2
child 986 6e74bf91f1df
Define own jsp-mode based on html-mode with JSP comment style.
.emacs-my
--- a/.emacs-my	Fri Nov 02 08:50:48 2012 +0200
+++ b/.emacs-my	Fri Nov 02 12:09:02 2012 +0200
@@ -2356,8 +2356,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (message "html")
 
-(add-to-list 'auto-mode-alist '("\\.jspf?\\'" . html-mode))
-
 (defun html-charref-escape-region (start end)
   (interactive "r")
   (save-excursion
@@ -2453,6 +2451,23 @@
        (add-to-list 'html-tag-alist '("style" (\n) ("type" "text/css") ))
        )))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(message "jsp")
+
+(define-derived-mode jsp-mode html-mode "JSP"
+  "JSP editing mode. Redefine HTML comment syntax to JSP."
+  (setq comment-start "<%--")
+  (setq comment-end "--%>")
+  (setq comment-start-skip "<[!%]--[ \t]*")
+  (setq comment-end-skip "[ \t]*--[% \t\n]*>")
+  (setq jsp-font-lock-syntactic-keywords
+        '(("\\(<\\)%--" (1 "< b"))
+          ("--%\\(>\\)" (1 "> b"))))
+  (setcdr (assoc 'font-lock-syntactic-keywords font-lock-defaults) 'jsp-font-lock-syntactic-keywords) )
+
+(add-to-list 'auto-mode-alist '("\\.jspf?\\'" . jsp-mode))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (message "sh, bash")