Commits

T. Budiman  committed a1de6bb

emacs configuration

  • Participants

Comments (0)

Files changed (2)

+(add-to-list 'load-path "~/.emacs.d/web/")
+(require 'web-mode)
+(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
+(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
+(setq web-mode-markup-indent-offset 2)
+(setq web-mode-css-indent-offset 2)
+(setq web-mode-code-indent-offset 2)
+(setq web-mode-indent-style 2)
+
+(add-hook 'java-mode-hook
+          (lambda ()
+            (setq c-basic-offset 4
+                  tab-width 4
+                  indent-tabs-mode nil)
+            "Treat Java 1.5 @-style annotations as comments."
+            (setq c-comment-start-regexp "(@|/(/|[*][*]?))")
+            (modify-syntax-entry ?@ "< b" java-mode-syntax-table)))
+
+;;remove all trailing whitespace and trailing blank lines before saving the file
+(add-hook 'before-save-hook 'delete-trailing-whitespace)
+(setq-default show-trailing-whitespace t)
+
+(custom-set-variables
+  ;; custom-set-variables was added by Custom.
+  ;; If you edit it by hand, you could mess it up, so be careful.
+  ;; Your init file should contain only one such instance.
+  ;; If there is more than one, they won't work right.
+ '(indent-tabs-mode nil))
+(custom-set-faces
+  ;; custom-set-faces was added by Custom.
+  ;; If you edit it by hand, you could mess it up, so be careful.
+  ;; Your init file should contain only one such instance.
+  ;; If there is more than one, they won't work right.
+ )

File .emacs.d/web/web-mode.el

+;;; -*- coding: utf-8 -*-
+
+;;; web-mode.el --- major mode for editing html templates
+
+;; Copyright 2011-2013 François-Xavier Bois
+
+;; Version: 6.0.39
+;; Author: François-Xavier Bois <fxbois AT Google Mail Service>
+;; Maintainer: François-Xavier Bois
+;; Created: July 2011
+;; Keywords: html template php javascript js css web
+;;           django jsp asp erb twig jinja blade dust closure
+;;           freemarker mustache velocity cheetah smarty
+;; URL: http://web-mode.org
+;; Repository: http://github.com/fxbois/web-mode
+
+;; =========================================================================
+;; This work is sponsored by Kernix : Digital Agency (Web & Mobile) in Paris
+;; =========================================================================
+
+;; This file is not part of Emacs
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Code goes here
+
+;;todo : commentaire d'une ligne ruby ou d'une ligne asp
+;;todo : ne mettre tag-type et tag-name que sur le '<'
+;;todo : créer tag-token pour différentier de part-token : tag-token=attr,comment ???
+
+(defgroup web-mode nil
+  "Major mode for editing web templates:
+   HTML files embedding parts (CSS/JavaScript)
+   and blocks (PHP, Erb, Django/Twig, Smarty, JSP, ASP, etc.)."
+  :version "6.0.39"
+  :group 'languages)
+
+(defgroup web-mode-faces nil
+  "Faces for syntax highlighting."
+  :group 'web-mode
+  :group 'faces)
+
+(defcustom web-mode-script-padding 1
+  "Script element left padding."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-style-padding 1
+  "Style element left padding."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-block-padding 0
+  "Multi-line block (PHP, Ruby, Java, etc.) left padding."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-markup-indent-offset 2
+  "HTML indentation level."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-css-indent-offset 2
+  "CSS indentation level."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-code-indent-offset 2
+  "Code (JavaScript, PHP, etc.) indentation level."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-disable-css-colorization (not (display-graphic-p))
+  "In a CSS block, do not set background according to the color: #xxx, rgb(x,x,x)."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-disable-auto-indentation (not (display-graphic-p))
+  "Disable auto-indentation."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-disable-auto-pairing (not (display-graphic-p))
+  "Disable auto-pairing."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-enable-whitespaces nil
+  "Enable whitespaces."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-enable-block-face nil
+  "Enable block face (useful for setting a background for example).
+See web-mode-block-face."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-enable-part-face nil
+  "Enable part face (useful for setting a background for example).
+See web-mode-part-face."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-enable-heredoc-fontification nil
+  "Enable heredoc fontification. The identifier should contain JS, JAVASCRIPT or HTML."
+  :type 'boolean
+  :group 'web-mode)
+
+(defcustom web-mode-enable-comment-keywords nil
+  "Enable highlight of keywords like FIXME, TODO, etc. in comments."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-comment-style 1
+  "Comment style : 2 = server comments."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-indent-style 1
+  "Indentation style.
+with value 2, HTML lines beginning text are also indented (do not forget side effects, ie. content of a textarea)."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-tag-auto-close-style 1
+  "Tag auto-close style:
+0=no auto-closing
+1=auto-close with </
+2=auto-close with > and </."
+  :type 'integer
+  :group 'web-mode)
+
+(defcustom web-mode-extra-php-constants '()
+  "A list of additional strings to treat as PHP constants."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-php-keywords '()
+  "A list of additional strings to treat as PHP keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-jsp-keywords '()
+  "A list of additional strings to treat as JSP keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-python-keywords '()
+  "A list of additional strings to treat as Python keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-erb-keywords '()
+  "A list of additional strings to treat as ERB keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-asp-keywords '()
+  "A list of additional strings to treat as ASP keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-asp-types '()
+  "A list of additional strings to treat as ASP types."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-aspx-keywords '()
+  "A list of additional strings to treat as ASPX keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-javascript-keywords '()
+  "A list of additional strings to treat as JS keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-razor-keywords '()
+  "A list of additional strings to treat as Razor keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defcustom web-mode-extra-comment-keywords '()
+  "A list of additional strings to treat as comment keywords."
+  :type 'list
+  :group 'web-mode)
+
+(defface web-mode-warning-face
+  '((t :inherit font-lock-warning-face))
+  "Face for warning."
+  :group 'web-mode-faces)
+
+(defface web-mode-preprocessor-face
+  '((t :inherit font-lock-preprocessor-face))
+  "Face for preprocessor."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-control-face
+  '((t :inherit font-lock-preprocessor-face))
+  "Face for preprocessor."
+  :group 'web-mode-faces)
+
+(defface web-mode-builtin-face
+  '((t :inherit font-lock-builtin-face))
+  "Face for builtins."
+  :group 'web-mode-faces)
+
+(defface web-mode-symbol-face
+  '((t :foreground "gold"))
+  "Face for symbols."
+  :group 'web-mode-faces)
+
+(defface web-mode-doctype-face
+  '((t :foreground "Grey"))
+  "Face for HTML doctype."
+  :group 'web-mode-faces)
+
+(defface web-mode-html-tag-face
+  '((t :foreground "Snow4"))
+  "Face for HTML tags."
+  :group 'web-mode-faces)
+
+(defface web-mode-html-attr-name-face
+  '((t :foreground "Snow3"))
+  "Face for HTML attribute names (including =)."
+  :group 'web-mode-faces)
+
+(defface web-mode-html-attr-value-face
+  '((t :inherit font-lock-string-face))
+  "Face for HTML attribute values."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-attr-name-face
+  '((t :inherit web-mode-html-attr-name-face))
+  "Face for block attribute names."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-attr-value-face
+  '((t :inherit web-mode-html-attr-value-face))
+  "Face for block attribute values."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-selector-face
+  '((t :inherit font-lock-keyword-face))
+  "Face for CSS rules."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-pseudo-class-face
+  '((t :inherit font-lock-builtin-face))
+  "Face for CSS pseudo-classes."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-at-rule-face
+  '((t :inherit font-lock-constant-face))
+  "Face for CSS at-rules."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-property-name-face
+  '((t :inherit font-lock-variable-name-face))
+  "Face for CSS props."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-color-face
+  '((t :inherit font-lock-builtin-face))
+  "Face for CSS colors (#xxx)."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-priority-face
+  '((t :inherit font-lock-builtin-face))
+  "Face for CSS priority (!important)."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-function-face
+  '((t :inherit font-lock-builtin-face))
+  "Face for CSS functions."
+  :group 'web-mode-faces)
+
+(defface web-mode-variable-name-face
+  '((t :inherit font-lock-variable-name-face))
+  "Face for variable names."
+  :group 'web-mode-faces)
+
+(defface web-mode-function-name-face
+  '((t :inherit font-lock-function-name-face))
+  "Face for function names."
+  :group 'web-mode-faces)
+
+(defface web-mode-string-face
+  '((t :inherit font-lock-string-face))
+  "Face for strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-string-face
+  '((t :inherit web-mode-string-face))
+  "Face for block strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-part-string-face
+  '((t :inherit web-mode-string-face))
+  "Face for part strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-javascript-string-face
+  '((t :inherit web-mode-string-face))
+  "Face for javascript strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-css-string-face
+  '((t :inherit web-mode-string-face))
+  "Face for css strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-json-key-face
+  '((t :foreground "plum"))
+  "Face for json key strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-json-context-face
+  '((t :foreground "orchid3"))
+  "Face for json context strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-json-string-face
+  '((t :inherit web-mode-string-face))
+  "Face for json strings."
+  :group 'web-mode-faces)
+
+(defface web-mode-comment-face
+  '((t :inherit font-lock-comment-face))
+  "Face for comments."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-comment-face
+  '((t :inherit web-mode-comment-face))
+  "Face for server comments."
+  :group 'web-mode-faces)
+
+(defface web-mode-part-comment-face
+  '((t :inherit web-mode-comment-face))
+  "Face for part comments."
+  :group 'web-mode-faces)
+
+(defface web-mode-constant-face
+  '((t :inherit font-lock-constant-face))
+  "Face for language constants."
+  :group 'web-mode-faces)
+
+(defface web-mode-type-face
+  '((t :inherit font-lock-type-face))
+  "Face for language types."
+  :group 'web-mode-faces)
+
+(defface web-mode-keyword-face
+  '((t :inherit font-lock-keyword-face))
+  "Face for language keywords."
+  :group 'web-mode-faces)
+
+(defface web-mode-param-name-face
+  '((t :foreground "Snow3"))
+  "Face for server attribute names."
+  :group 'web-mode-faces)
+
+(defface web-mode-whitespace-face
+  '((t :background "DarkOrchid4"))
+  "Face for whitespaces."
+  :group 'web-mode-faces)
+
+(defface web-mode-block-face
+  '((((class color) (min-colors 88) (background dark))
+     :background "grey18")
+    (((class color) (min-colors 88) (background light))
+     :background "LightYellow1")
+    (((class color) (min-colors 16) (background dark))
+     :background "grey18")
+    (((class color) (min-colors 16) (background light))
+     :background "LightYellow1")
+    (((class color) (min-colors 8))
+     :background "Black")
+    (((type tty) (class mono))
+     :inverse-video t)
+    (t :background "grey"))
+  "Face for blocks (useful for setting a background for example).
+Must be used in conjunction with web-mode-enable-block-face."
+  :group 'web-mode-faces)
+
+(defface web-mode-part-face
+  '((t :inherit web-mode-block-face))
+  "Face for parts."
+  :group 'web-mode-faces)
+
+(defface web-mode-folded-face
+  '((t :underline t))
+  "Overlay face for folded."
+  :group 'web-mode-faces)
+
+(defface web-mode-comment-keyword-face
+  '((t :weight bold :box t))
+  "Comment keywords."
+  :group 'web-mode-faces)
+
+(defvar web-mode-void-elements
+  '("area" "base" "br" "col" "command" "embed" "hr" "img" "input" "keygen"
+    "link" "meta" "param" "source" "track" "wbr")
+  "Void (self-closing) tags.")
+
+(defvar web-mode-text-properties
+  '(part-side nil part-token nil part-language nil tag-name nil tag-type nil tag-beg nil tag-end nil block-side nil block-token nil block-beg nil block-end nil face nil)
+  "Text properties used for fontification and indentation.")
+
+(defvar web-mode-is-scratch nil
+  "Is scratch buffer ?")
+
+(defvar web-mode-time nil
+  "For benchmarking")
+
+(defvar web-mode-expand-initial-pos nil
+  "First mark pos.")
+
+(defvar web-mode-expand-previous-state ""
+  "Last mark state.")
+
+;;"<\\(/?[[:alpha:]@#][[:alnum:]:_]*\\)"
+(defvar web-mode-tag-regexp "<\\(/?[[:alpha:]][[:alnum:]]*\\)"
+  "Regular expression for HTML/XML tag.")
+
+(defvar web-mode-start-tag-regexp "<\\([[:alpha:]][[:alnum:]]*\\)"
+  "Regular expression for HTML/XML start tag.")
+
+(defvar web-mode-whitespaces-regexp
+  "^[ \t]\\{2,\\}$\\| \t\\|\t \\|[ \t]+$\\|^[ \n\t]+\\'\\|^[ \t]?[\n]\\{2,\\}"
+  "Regular expression for whitespaces.")
+
+(defvar web-mode-engine nil
+  "Template engine")
+
+(defvar web-mode-engine-families
+  '(("asp"        . ("asp"))
+    ("aspx"       . ("aspx"))
+    ("blade"      . ("laravel"))
+    ("closure"    . ("soy"))
+    ("ctemplate"  . ("mustache" "handlebars" "hapax" "ngtemplate" "ember" "kite"))
+    ("django"     . ("dtl" "twig" "swig" "jinja" "jinja2" "erlydtl"))
+    ("dust"       . ())
+    ("erb"        . ("eruby" "erubis"))
+    ("go"         . ("gtl"))
+    ("jsp"        . ())
+    ("python"     . ())
+    ("razor"      . ("play" "play2"))
+    ("velocity"   . ("vtl" "cheetah")))
+  "Engine name aliases")
+
+(defvar web-mode-content-types
+  '(("css"        . "\\.css\\'")
+    ("javascript" . "\\.js\\'")
+    ("json"       . "\\.\\(json\\|jsonld\\)\\'")
+    ("html"       . "."))
+  "content types")
+
+(defvar web-mode-engine-file-regexps
+  '(("asp"        . "\\.asp\\'")
+    ("aspx"       . "\\.as[cp]x\\'")
+    ("blade"      . "\\.blade")
+    ("closure"    . "\\.soy\\'")
+    ("ctemplate"  . "\\.\\(chtml\\)\\'")
+    ("django"     . "\\.\\(djhtml\\|tmpl\\|dtl\\)\\'")
+    ("django"     . "twig")
+    ("dust"       . "\\.dust\\'")
+    ("erb"        . "\\.\\(erb\\|rhtml\\)\\'")
+    ("freemarker" . "\\.ftl\\'")
+    ("go"         . "\\.go\\(html\\|tmpl\\)\\'")
+    ("handlebars" . "\\(handlebars\\|.\\hbs\\'\\)")
+    ("jsp"        . "\\.jsp\\'")
+    ("mustache"   . "\\.mustache\\'")
+    ("php"        . "\\.\\(php\\|ctp\\|psp\\|inc\\)\\'")
+    ("python"     . "\\.pml\\'")
+    ("razor"      . "play\\|\\.scala\\.\\|\\.cshtml\\'\\|\\.vbhtml\\'")
+    ("smarty"     . "\\.tpl\\'")
+    ("velocity"   . "\\.\\(vsl\\|vtl\\|vm\\)\\'"))
+  "Engine file extensions.")
+
+(defvar web-mode-smart-quotes
+  '("«" . "»")
+  "Preferred smart quotes")
+
+(defvar web-mode-xml-chars
+  '((?\& . "&amp;")
+    (?\< . "&lt;")
+    (?\> . "&gt;"))
+  "XML chars")
+
+(defvar web-mode-html-entities
+  '(("eacute" . "é")
+    ("egrave" . "è")
+    ("middot" . "·")
+    ("quot"   . "\"")
+    ("amp"    . "&")
+    ("lt"     . "<")
+    ("gt"     . ">")
+    ("laquo"  . "«")
+    ("raquo"  . "»")
+    ("lsquo"  . "‘")
+    ("rsquo"  . "’")
+    ("ldquo"  . "“")
+    ("rdquo"  . "”")
+    ("apos"   . "'"))
+  "HTML entities")
+
+(defvar web-mode-snippets
+  (list
+   '("table"
+     "<table><tbody>\n<tr>\n<td>"
+     "</td>\n<td></td>\n</tr>\n</tbody></table>")
+   '("ul"
+     "<ul>\n<li>"
+     "</li>\n<li></li>\n</ul>")
+   '("if"
+     "<?php if ( as ): ?>\n"
+     "\n<?php endif; ?>")
+   '("for"
+     "<?php for ( ; ; ): ?>\n"
+     "\n<?php endfor; ?>")
+   '("foreach"
+     "<?php foreach ( as ): ?>\n"
+     "\n<?php endforeach; ?>")
+   '("html5"
+     "<!doctype html>\n<html>\n<head>\n<title></title>\n<meta charset=\"utf-8\" />\n</head>\n<body>\n"
+     "\n</body>\n</html>")
+   )
+  "Code snippets")
+
+(defvar web-mode-auto-pairs
+  (list
+   '("<?p"  "hp  ?>"   "\\?>"  3)
+   '("<? "  "?>"       "\\?>"  0)
+   '("<?="  "?>"       "\\?>"  0)
+   '("<!-"  "-  -->"   "--"    2)
+   '("<%-"  "-  --%>"  "--"    2)
+   '("<%@"  "  %>"     "%>"    1)
+   '("<%="  "%>"       "%>"    0)
+   '("<% "  " %>"      "%>"    0)
+   '("{{ "  " }}"      "}}"    0)
+   '("{% "  " %}"      "%}"    0)
+   '("{# "  " #}"      "#}"    0)
+   )
+  "Auto-Pairs")
+
+(defvar web-mode-content-type ""
+  "Buffer file type.")
+
+(defvar web-mode-comments-invisible nil
+  "Comments visbility.")
+
+(defvar web-mode-is-narrowed nil
+  "Buffer has been narrowed.")
+
+(defvar web-mode-hook nil
+  "List of functions to be executed with web-mode.")
+
+(defvar web-mode-buffer-highlighted nil
+  "Is buffer highlighted.")
+
+(defvar web-mode-display-table nil
+  "Display table.")
+
+(defvar web-mode-hl-line-mode-flag nil
+  "Is hl-line-mode enabled ?")
+
+(defvar web-mode-blade-active-blocks
+  '("else" "elseif" "foreach" "forelse" "for" "if" "section" "unless" "while")
+  "Blade controls.")
+
+(defvar web-mode-closure-active-blocks
+  '("call" "case" "default" "deltemplate" "else" "elseif" "for" "foreach"
+    "if" "ifempty" "let" "literal" "msg" "param" "switch" "template")
+  "Closure controls.")
+
+(defvar web-mode-django-active-blocks
+  '("assets" "autoescape" "block" "cache" "call"
+    "elif" "else" "elseif" "embed" "filter" "foreach" "for"
+    "ifchanged" "ifequal" "ifnotequal" "if"
+    "macro" "draw" "random" "sandbox" "spaceless" "trans" "with")
+  "Django controls.")
+
+(defvar web-mode-go-active-blocks
+  '("else" "end" "if" "range" "with")
+  "Go controls.")
+
+(defvar web-mode-php-active-blocks
+  '("declare" "else" "elseif" "for" "foreach" "if" "while")
+  "PHP controls.")
+
+(defvar web-mode-smarty-active-blocks
+  '("block" "else" "elseif" "foreach" "for" "if" "section" "while")
+  "Smarty controls.")
+
+(defvar web-mode-velocity-active-blocks
+  '("define" "else" "elseif" "end" "for" "foreach" "if" "macro")
+  "Velocity controls.")
+
+(defvar web-mode-active-block-regexps
+  (list
+   (cons "asp"        "----")
+   (cons "aspx"       "----")
+   (cons "blade"      (concat "@\\(end\\)?" (regexp-opt web-mode-blade-active-blocks t)))
+   (cons "closure"    (concat "{/?" (regexp-opt web-mode-closure-active-blocks t)))
+   (cons "ctemplate"  "{{[#^/]\\([[:alnum:]_]+\\)")
+   (cons "django"     (concat "{%[-]?[ ]+\\(end\\)?" (regexp-opt web-mode-django-active-blocks t)))
+   (cons "dust"       "{[#/:?@><+^]\\([[:alpha:]_]+\\)")
+   (cons "erb"        "<%[-]?[ ]+\\(.* do \\|for\\|unless\\|end\\|if\\|else\\)")
+   (cons "freemarker" "</?\\([[:alpha:]]+:[[:alpha:]]+\\)\\|[[<]/?[@#]\\([[:alpha:]]+\\)")
+   (cons "go"         (concat "{{[ ]*" (regexp-opt web-mode-go-active-blocks t)))
+   (cons "jsp"        "</?\\([[:alpha:]]+:[[:alpha:]]+\\)")
+   (cons "php"        (concat "<\\?\\(php[ ]+\\|[ ]*\\)?\\(end\\)?" (regexp-opt web-mode-php-active-blocks t)))
+   (cons "razor"      "----")
+   (cons "smarty"     (concat "{/?" (regexp-opt web-mode-smarty-active-blocks t)))
+   (cons "velocity"   (concat "#" (regexp-opt web-mode-velocity-active-blocks t))))
+  "Engine control regexps")
+
+(defvar web-mode-close-block-regexps
+  '(("asp"        . "----")
+    ("aspx"       . "----")
+    ("blade"      . "@\\\(end\\|else\\)")
+    ("closure"    . "{\\(/\\|else\\|case\\|default\\|ifempty\\)")
+    ("ctemplate"  . "{{/")
+    ("django"     . "{%[-]?[ ]+\\(end\\|else\\|elseif\\|elif\\)")
+    ("dust"       . "{\\(/\\|:else\\)")
+    ("erb"        . "<%[-]?[ ]+\\(end\\|else\\)")
+    ("freemarker" . "[<[]\\(/#\\|#els\\|#break\\)")
+    ("go"         . "{{[ ]*\\(end\\|else\\)")
+    ("jsp"        . "</")
+    ("php"        . "<\\?\\(php[ ]+\\|[ ]*\\)?\\(end\\|else\\|}\\)")
+    ("razor"      . "}")
+    ("smarty"     . "{\\(/\\|else\\)")
+    ("velocity"   . "#\\(end\\|else\\)"))
+  "Close control blocks.")
+
+(defvar web-mode-block-regexps
+  '(("asp"        . "<%")
+    ("aspx"       . "<%")
+    ("blade"      . "{{\\|^[ \t]*@[[:alpha:]]")
+    ("closure"    . "{.\\|/\\*\\| //")
+    ("ctemplate"  . "[$]?{{.")
+    ("django"     . "{[#{%]")
+    ("dust"       . "{.")
+    ("erb"        . "<%\\|^%.")
+    ("freemarker" . "<%\\|${\\|</?[[:alpha:]]+:[[:alpha:]]\\|</?[@#].\\|\\[/?[@#].")
+    ("go"         . "{{.")
+    ("jsp"        . "<%\\|${\\|</?[[:alpha:]]+:[[:alpha:]]")
+    ("php"        . "<\\?")
+    ("python"     . "<\\?")
+    ("razor"      . "@.")
+    ("smarty"     . "{[[:alpha:]#$/*\"]")
+    ("velocity"   . "^[ \t]*#[[:alpha:]#*]\\|$[[:alpha:]!{]"))
+  "Engine block regexps.")
+
+(defvar web-mode-block-regexp nil
+  "Regular expression for identifying blocks.")
+
+(defvar web-mode-active-block-regexp nil
+  "Engine control regexp")
+
+(defvar web-mode-close-block-regexp nil
+  "Engine end control regexp")
+
+(defvar web-mode-engine-control-matcher nil
+  "Engine control match")
+
+(defvar web-mode-comment-keywords
+  (regexp-opt
+   (append web-mode-extra-comment-keywords
+           '("FIXME" "TODO" "BUG" "KLUDGE" "WORKAROUND"
+             "OPTIMIZE" "HACK" "REFACTOR")))
+  "Comment keywords.")
+
+(defvar web-mode-php-constants
+  (regexp-opt
+   (append web-mode-extra-php-constants
+           '("TRUE" "FALSE" "NULL" "true" "false" "null"
+             "STR_PAD_LEFT" "STR_PAD_RIGHT"
+             "ENT_COMPAT" "ENT_QUOTES" "ENT_NOQUOTES" "ENT_IGNORE"
+             "ENT_SUBSTITUTE" "ENT_DISALLOWED" "ENT_HTML401" "ENT_XML1"
+             "ENT_XHTML" "ENT_HTML5"
+             "LIBXML_NOBLANKS")))
+  "PHP constants.")
+
+(defvar web-mode-php-keywords
+  (regexp-opt
+   (append web-mode-extra-php-keywords
+           '("and" "array" "as" "break"
+             "callable" "case" "catch"  "catch all" "class" "const" "continue"
+             "default" "die" "do"
+             "echo" "else" "elseif" "empty"
+             "endfor" "endforeach" "endif" "endswitch" "endwhile" "exit" "extends"
+             "finally" "for" "foreach" "function" "global"
+             "if" "include" "include_once" "instanceof" "interface" "isset"
+             "list" "next" "new" "or"
+             "private" "protected" "public"
+             "require" "require_once" "return" "static" "switch" "try" "throw" "unset" "use"
+             "var" "when" "while" "xor" "yield")))
+  "PHP keywords.")
+
+(defvar web-mode-php-types
+  (eval-when-compile
+    (regexp-opt
+     '("array" "bool" "boolean" "char" "const" "double" "float"
+       "int" "integer" "long" "mixed" "object" "real" "string"
+       "Exception")))
+  "PHP types.")
+
+(defvar web-mode-css-at-rules
+  (eval-when-compile
+    (regexp-opt
+     '("charset" "import" "media" "page" "font-face" "namespace")))
+  "CSS at-rules.")
+
+(defvar web-mode-css-pseudo-classes
+  (eval-when-compile
+    (regexp-opt
+     '("active" "after" "before" "checked" "disabled" "empty" "enabled"
+       "first" "first-child" "first-letter" "first-line" "first-of-type" "focus"
+       "hover" "lang" "last-child" "last-of-type" "left" "link"
+       "not" "nth-child" "nth-last-child" "nth-last-of-type" "nth-of-type"
+       "only-child" "only-of-type"
+       "right" "root" "selection" "target" "visited")))
+  "CSS pseudo-classes (and pseudo-elements).")
+
+(defvar web-mode-python-keywords
+  (regexp-opt
+   (append web-mode-extra-python-keywords
+           '("False" "class" "finally" "is" "return"
+             "None" "continue" "for" "lambda" "try"
+             "True" "def" "from" "nonlocal" "while"
+             "and" "del" "global" "not" "with"
+             "as" "elif" "if" "or" "yield"
+             "assert" "else" "import" "pass"
+             "break" "except" "in" "raise")))
+  "Python keywords.")
+
+(defvar web-mode-jsp-keywords
+  (regexp-opt
+   (append web-mode-extra-jsp-keywords
+           '("case" "catch" "do" "else" "end" "false" "for" "function"
+             "if" "in" "include" "new"
+             "package" "page" "private" "protected" "public"
+             "return" "tag" "taglib" "throw" "throws" "true" "try"
+             "void" "while")))
+  "JSP keywords.")
+
+(defvar web-mode-erb-keywords
+  (regexp-opt
+   (append web-mode-extra-erb-keywords
+           '("BEGIN" "END" "__FILE__" "__LINE__"
+             "alias" "and" "begin" "break" "button_to_function"
+             "case" "class" "csrf_meta_tag"
+             "def" "defined" "do" "else" "elsif" "end"
+             "ensure" "escape_javascript" "false" "for" "form_for" "h" "html_escape"
+             "if" "in" "j" "javascript_include_tag" "javascript_tag"
+             "link_to" "link_to_function" "module" "next" "nil" "not"
+             "or" "package" "puts" "raw" "redo" "render" "rescue" "retry" "return"
+             "self" "super" "then" "true" "u" "undef"
+             "unless" "until" "url_encode" "when" "while" "yield"
+             )))
+  "ERB keywords.")
+
+(defvar web-mode-asp-keywords
+  (regexp-opt
+   (append web-mode-extra-asp-keywords
+           '("If" "Then" "Each" "End" "Set" "Dim" "On" "For" "Next" "Rem" "Empty"
+             "IsArray" "Erase" "LBound" "UBound" "Let" "Next" "Nothing" "Null" "In"
+             "True" "False" "Do" "Loop" "Each" "Select" "Case"
+             "While" "Wend" "Err")))
+  "ASP keywords.")
+
+(defvar web-mode-asp-types
+  (regexp-opt
+   (append web-mode-extra-asp-types
+           '("Application" "ASPError" "Request" "Response" "Server" "Session")))
+  "ASP types.")
+
+(defvar web-mode-aspx-keywords
+  (regexp-opt
+   (append web-mode-extra-aspx-keywords
+           '("case" "catch" "do" "else" "end"
+             "for" "foreach" "function"
+             "if" "in" "include"
+             "new" "package" "page" "return"
+             "tag" "throw" "throws" "try" "while")))
+  "ASP.Net keywords.")
+
+(defvar web-mode-smarty-keywords
+  (regexp-opt
+   '("as"))
+  "Smarty keywords.")
+
+(defvar web-mode-velocity-keywords
+  (eval-when-compile
+    (regexp-opt
+     '("in")))
+  "Velocity keywords.")
+
+(defvar web-mode-freemarker-keywords
+  (eval-when-compile
+    (regexp-opt
+     '("as" "list"))))
+
+(defvar web-mode-go-keywords
+  (eval-when-compile
+    (regexp-opt
+     '("define" "else" "end" "if" "pipeline" "range" "template" "with"))))
+
+(defvar web-mode-go-functions
+  (eval-when-compile
+    (regexp-opt
+     '("and" "call" "html" "index" "js" "len" "not" "or"
+       "print" "printf" "println" "urlquery")))
+  "Go functions.")
+
+(defvar web-mode-django-filters
+  (eval-when-compile
+    (regexp-opt
+     '("add" "addslashes" "capfirst" "center" "cut"
+       "date" "default" "default_if_none" "dictsort"
+       "dictsortreversed" "divisibleby"
+       "escape" "escapejs" "filesizeformat" "first"
+       "fix_ampersands" "floatformat"
+       "force_escape" "format_integer" "format_number"
+       "get_digit" "iriencode" "join"
+       "last" "length" "length_is" "linebreaks" "linebreaksbr" "linenumbers"
+       "ljust" "lower" "make_list"
+       "phonenumeric" "pluralize" "pprint"
+       "random" "random_num" "random_range" "removetags" "rjust"
+       "safe" "safeseq" "slice" "slugify" "stringformat" "striptags"
+       "time" "timesince" "timeuntil" "title" "truncatechars" "truncatewords"
+       "truncatewords_html" "unordered_list" "upper" "urlencode"
+       "urlize" "urlizetrunc"
+       "wordcount" "wordwrap" "yesno")))
+  "Django filters.")
+
+(defvar web-mode-closure-keywords
+  (eval-when-compile
+    (regexp-opt
+     '("in" "and" "not" "or")
+     ))
+  "Closure keywords")
+
+(defvar web-mode-django-keywords
+  (eval-when-compile
+    (regexp-opt
+     '("and" "as" "autoescape" "block" "blocktrans" "break"
+       "cache" "call" "comment" "context" "continue" "csrf_token" "cycle"
+       "debug" "do"
+       "embed" "empty" "else" "elseif" "elif" "endautoescape" "endblock"
+       "endcache" "endcall" "endembed" "endfilter" "endfor" "endif"
+       "endifchanged" "endifequal" "endifnotequal" "endmacro" "endrandom" "endraw"
+       "endsandbox" "endset" "endspaceless" "endtrans" "endwith"
+       "extends" "false" "filter" "firstof" "flush" "for" "from"
+       "if" "ifchanged" "ifequal" "ifnotequal" "ignore" "import"
+       "in" "include" "is"
+       "load" "macro" "missing" "none" "not" "now" "or" "pluralize"
+       "random" "raw" "regroup" "trans" "true"
+       "sandbox" "set" "spaceless" "ssi" "static" "templatetag" "trans"
+       "use" "url" "var" "verbatim" "widthratio" "with")))
+  "Django keywords.")
+
+(defvar web-mode-directives
+  (eval-when-compile
+    (regexp-opt
+     '("include" "page" "taglib"
+       "Assembly" "Control" "Implements" "Import"
+       "Master" "OutputCache" "Page" "Reference" "Register")))
+  "Directives.")
+
+(defvar web-mode-javascript-keywords
+  (regexp-opt
+   (append web-mode-extra-javascript-keywords
+           '("arguments" "break" "case" "catch" "class" "const" "continue"
+             "debugger" "default" "delete" "do" "else" "enum" "eval"
+             "export" "extends" "false" "finally" "for" "function" "if"
+             "implements" "import" "in" "instanceof" "interface" "let"
+             "new" "null" "package" "private" "protected" "public"
+             "return" "static" "super" "switch" "this" "throw"
+             "true" "try" "typeof" "undefined" "var" "void" "while" "with" "yield"
+             )))
+  "JavaScript keywords.")
+
+(defvar web-mode-razor-keywords
+  (regexp-opt
+   (append web-mode-extra-razor-keywords
+           '("false" "true" "foreach" "if" "in" "var" "for" "display")))
+  "Razor keywords.")
+
+(defvar web-mode-django-expr-font-lock-keywords
+  (list
+   '("{{\\|}}" 0 'web-mode-preprocessor-face)
+   (cons (concat "\\<\\(" web-mode-django-filters "\\)\\>") '(1 'web-mode-function-name-face))
+   '("[[:alnum:]_]+" 0 'web-mode-variable-name-face)
+   )
+  "Font lock keywords for dtl expr")
+
+(defvar web-mode-dust-font-lock-keywords
+  (list
+   '("/?}\\|{[#/:?@><+^]?" 0 'web-mode-preprocessor-face)
+   '("{[#:/?@><+^]\\([[:alpha:]_]+\\)" 1 'web-mode-block-control-face)
+   '(":\\([[:alpha:]]+\\)" 1 'web-mode-keyword-face)
+   '("\\<\\([[:alpha:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_]*\\)"
+     (1 'web-mode-block-attr-name-face)
+     (2 'web-mode-block-attr-value-face))
+   '("\\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-smarty-font-lock-keywords
+  (list
+   '("}\\|{/?" 0 'web-mode-preprocessor-face)
+   (cons (concat "[ ]\\(" web-mode-smarty-keywords "\\)[ ]") '(1 'web-mode-keyword-face))
+   '("{/?\\([[:alpha:]_]+\\)" 1 'web-mode-block-control-face)
+   '("\\<\\([$]\\)\\([[:alnum:]_]+\\)" (1 nil) (2 'web-mode-variable-name-face))
+   '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '(" \\(\\sw+[ ]?=\\)" 1 'web-mode-param-name-face)
+   '(" \\(\\sw+\\)[ }]" 1 'web-mode-param-name-face)
+   '("|\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face)
+   '("\\(->\\)\\(\\sw+\\)" (1 nil) (2 'web-mode-variable-name-face))
+   '("[.]\\([[:alnum:]_-]+\\)[ ]?(" (1 'web-mode-function-name-face))
+   '("[.]\\([[:alnum:]_]+\\)" (1 'web-mode-variable-name-face))
+   '("#\\([[:alnum:]_]+\\)#" 1 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-velocity-font-lock-keywords
+  (list
+   '("\\([#]\\)\\([[:alpha:]]+\\)\\>"
+     (1 'web-mode-preprocessor-face)
+     (2 'web-mode-block-control-face))
+   (cons (concat "[ ]\\(" web-mode-velocity-keywords "\\)[ ]") '(1 'web-mode-keyword-face t t))
+   '("#macro([ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-function-name-face)
+   '("[.]\\([[:alnum:]_-]+\\)" 1 'web-mode-variable-name-face)
+   '("\\<\\($[!]?[{]?\\)\\([[:alnum:]_-]+\\)[}]?" (1 nil) (2 'web-mode-variable-name-face))
+   ))
+
+(defvar web-mode-django-code-font-lock-keywords
+  (list
+   '("{%\\|%}" 0 'web-mode-preprocessor-face)
+   (cons (concat "[% ]\\(" web-mode-django-keywords "\\)[ %]") '(1 'web-mode-keyword-face t t))
+   (cons (concat "\\<\\(" web-mode-django-filters "\\)\\>") '(1 'web-mode-function-name-face t t))
+   '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("[[:alnum:]_]+" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-ctemplate-font-lock-keywords
+  (list
+   '("${{\\|{{[>#/{%^&]?\\|[}]?}}" 0 'web-mode-preprocessor-face)
+   '("{{[#/>][ ]*\\([[:alnum:]_]+\\)" 1 'web-mode-block-control-face)
+   '("[[:alnum:]_]" 0 'web-mode-variable-name-face)
+   '("[ ]+\\([[:alnum:]_]+=\\)" 1 'web-mode-param-name-face t t)
+   '("[:=]\\([[:alpha:]_]+\\)" 1 'web-mode-function-name-face t t)
+   ))
+
+(defvar web-mode-razor-font-lock-keywords
+  (list
+   '("@" 0 'web-mode-preprocessor-face)
+   (cons (concat "\\<\\(" web-mode-razor-keywords "\\)\\>") '(1 'web-mode-keyword-face t t))
+   '("\\<\\([[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("<\\([[:alnum:]_]+\\)>" 1 'web-mode-type-face)
+   '("\\<\\([[:alnum:].]+\\)[ ]+[{[:alpha:]]+" 1 'web-mode-type-face)
+   '("[[:alnum:]_]+" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-closure-font-lock-keywords
+  (list
+   '("{/?\\|/?}" 0 'web-mode-preprocessor-face)
+   '("{/?\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face)
+   '("{param[ ]+\\([[:alnum:]]+\\)" 1 'web-mode-symbol-face)
+   '("\\<\\(true\\|false\\|null\\)\\>" 1 'web-mode-type-face)
+   (cons (concat "\\<\\(" web-mode-closure-keywords "\\)\\>") '(1 'web-mode-keyword-face))
+   '("{\\(alias\\|call\\|delcall\\|delpackage\\|deltemplate\\|namespace\\|template\\)[ ]+\\([[:alnum:].]+\\)" 2 'web-mode-constant-face)
+   '("\\(allowemptydefault\\|data\\|desc\\|meaning\\|autoescape\\|private\\|variant\\)=" 0 'web-mode-block-attr-name-face)
+   '("|\\([[:alpha:]]+\\)" 1 'web-mode-function-name-face)
+   '("\\<\\([[:alnum:]]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("$\\([[:alnum:]._]+\\)" 1 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-go-font-lock-keywords
+  (list
+   '("{{\\|}}" 0 'web-mode-preprocessor-face)
+   '("{{\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face)
+   (cons (concat "\\<\\(" web-mode-go-keywords "\\)\\>") '(1 'web-mode-keyword-face))
+   (cons (concat "\\<\\(" web-mode-go-functions "\\)\\>") '(1 'web-mode-function-name-face))
+   '("[$.]\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face t t)
+   ))
+
+(defvar web-mode-expression-font-lock-keywords
+  (list
+   '("<%\\$\\|%>" 0 'web-mode-preprocessor-face)
+   '("[[:alpha:]_]" 0 'web-mode-variable-name-face)
+   ))
+
+;; css rule = selector + declaration
+(defvar web-mode-selector-font-lock-keywords
+  (list
+   (cons (concat "@\\(" web-mode-css-at-rules "\\)\\>") '(1 'web-mode-css-at-rule-face))
+   (cons (concat ":\\(" web-mode-css-pseudo-classes "\\)\\>") '(1 'web-mode-css-pseudo-class-face))
+   '("[[:alnum:]-]+" 0 'web-mode-css-selector-face)
+   ))
+
+(defvar web-mode-declaration-font-lock-keywords
+  (list
+   (cons (concat "@\\(" web-mode-css-at-rules "\\)\\>") '(1 'web-mode-css-at-rule-face))
+   '("\\([[:alpha:]-]\\{3,\\}\\)[ ]?:" 1 'web-mode-css-property-name-face)
+   '("\\([[:alpha:]-]+\\)[ ]?(" 1 'web-mode-css-function-face)
+   '("#[[:alnum:]]\\{3,6\\}" 0 'web-mode-css-color-face t t)
+   '("![ ]?important" 0 'web-mode-css-priority-face t t)
+   ))
+
+(defvar web-mode-html-font-lock-keywords
+  (list
+   '("</?[[:alnum:]]+\\|>" 0 'web-mode-html-tag-face)
+   '(" \\([[:alnum:]-]+=\\)\\(\"[^\"]+\"\\)"
+     (1 'web-mode-html-attr-name-face)
+     (2 'web-mode-html-attr-value-face))
+   ))
+
+(defvar web-mode-javascript-font-lock-keywords
+  (list
+   (cons (concat "\\<\\(" web-mode-javascript-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   '("\\<new \\([[:alnum:]_.]+\\)\\>" 1 'web-mode-type-face)
+   '("\\<\\([[:alnum:]_]+\\):[ ]*function[ ]*(" 1 'web-mode-function-name-face)
+   '("function[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face)
+   '("\\([[:alnum:]]+\\):" 1 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-asp-font-lock-keywords
+  (list
+   '("<%=?\\|%>" 0 'web-mode-preprocessor-face)
+   '("\\<\\([[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   (cons (concat "\\<\\(" web-mode-asp-types "\\)\\>") '(0 'web-mode-type-face))
+   (cons (concat "\\<\\(" web-mode-asp-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   ))
+
+(defvar web-mode-aspx-font-lock-keywords
+  (list
+   '("<%[:=#]?\\|%>" 0 'web-mode-preprocessor-face)
+   (cons (concat "\\<\\(" web-mode-aspx-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   '("\\<\\([[:alnum:].]+\\)[ ]+[[:alpha:]]+" 1 'web-mode-type-face)
+   ))
+
+;;Unified Expression Language
+(defvar web-mode-uel-font-lock-keywords
+  (list
+   '("[$#{]{\\|}" 0 'web-mode-preprocessor-face)
+   '("\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("[[:alpha:]_]" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-freemarker-square-font-lock-keywords
+  (list
+   '("\\[/?[#@]\\|/?>\\|/?\\]" 0 'web-mode-preprocessor-face)
+   '("\\[/?[#@]\\([[:alpha:]_.]*\\)" 1 'web-mode-block-control-face)
+   '("#\\(macro\\|function\\) \\([[:alpha:]]+\\)" 2 'web-mode-function-name-face)
+   (cons (concat "\\<\\(" web-mode-freemarker-keywords "\\)\\>") '(1 'web-mode-keyword-face))
+   '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-freemarker-font-lock-keywords
+  (list
+   '("</?[#@]\\|/?>\\|/?>" 0 'web-mode-preprocessor-face)
+   '("</?[#@]\\([[:alpha:]_.]*\\)" 1 'web-mode-block-control-face)
+   '("#\\(macro\\|function\\) \\([[:alpha:]]+\\)" 2 'web-mode-function-name-face)
+   (cons (concat "\\<\\(" web-mode-freemarker-keywords "\\)\\>") '(1 'web-mode-keyword-face))
+   '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face)
+   ))
+
+;;TODO : definir web-mode-block-attr-name-face et web-mode-block-attr-name-face
+(defvar web-mode-jsp-tag-font-lock-keywords
+  (list
+   '("</?\\|/?>" 0 'web-mode-preprocessor-face)
+   '("</?\\([[:alpha:]]+:[[:alpha:]]+\\)" 1 'web-mode-block-control-face)
+   '("\\<\\([[:alpha:]]+=\\)\\(\"[^\"]*\"\\)"
+     (1 'web-mode-block-attr-name-face t t)
+     (2 'web-mode-block-attr-value-face t t))
+   ))
+
+(defvar web-mode-jsp-font-lock-keywords
+  (list
+   '("-?%>\\|<%\\(!\\|=\\|#=\\)?" 0 'web-mode-preprocessor-face)
+   '("\\(throws\\|new\\|extends\\)[ ]+\\([[:alnum:].]+\\)" 2 'web-mode-type-face)
+   (cons (concat "\\<\\(" web-mode-jsp-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   '("\\<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("@\\(\\sw*\\)" 1 'web-mode-variable-name-face)
+   '("\\<\\([[:alnum:].]+\\)[ ]+[{[:alpha:]]+" 1 'web-mode-type-face)
+   ))
+
+(defvar web-mode-directive-font-lock-keywords
+  (list
+   '("<%@\\|%>" 0 'web-mode-preprocessor-face)
+   '("<%@[ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-block-control-face)
+   '("\\<\\([[:alpha:]]+=\\)\\(\"[^\"]*\"\\)"
+     (1 'web-mode-block-attr-name-face t t)
+     (2 'web-mode-block-attr-value-face t t))
+   ))
+
+(defvar web-mode-erb-font-lock-keywords
+  (list
+   '("-?%>\\|^%\\|<%[=-]?" 0 'web-mode-preprocessor-face)
+   '(":\\([[:alnum:]_]+\\)" 1 'web-mode-symbol-face)
+   '("\\([[:alnum:]_]+\\):[ ]+" 1 'web-mode-symbol-face)
+   '("\\<\\([[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-name-face)
+   (cons (concat "\\<\\(" web-mode-erb-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   '("@\\(\\sw*\\)" 1 'web-mode-variable-name-face)
+   '("class[ ]+\\(\\sw*\\)" 1 'web-mode-type-face)
+   '("def[ ]+\\(\\sw*\\)" 1 'web-mode-function-name-face)
+   '("[[:alpha:]][[:alnum:]_]*" 0 'web-mode-variable-name-face)
+   ))
+
+(defvar web-mode-python-font-lock-keywords
+  (list
+   '("<\\?\\|\\?>" 0 'web-mode-preprocessor-face)
+   (cons (concat "\\<\\(" web-mode-python-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   ))
+
+(defvar web-mode-php-font-lock-keywords
+  (list
+   '("<\\?\\(php\\|=\\)?\\|\\?>" 0 'web-mode-preprocessor-face)
+   (cons (concat "\\<\\(" web-mode-php-keywords "\\)\\>") '(0 'web-mode-keyword-face))
+   (cons (concat "(\\<\\(" web-mode-php-types "\\)\\>") '(1 'web-mode-type-face))
+   (cons (concat "\\<\\(" web-mode-php-constants "\\)\\>") '(0 'web-mode-constant-face))
+   '("\\<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-name-face)
+   '("[[:alnum:]_][ ]?::[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-constant-face)
+   '("->[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face)
+   '("\\<\\([[:alnum:]_]+\\)[ ]?::" 1 'web-mode-type-face)
+   '("\\<\\(instanceof\\|class\\|extends\\|new\\)[ ]+\\([[:alnum:]_]+\\)" 2 'web-mode-type-face)
+   '("\\<\\([$]\\)\\([[:alnum:]_]*\\)" (1 nil) (2 'web-mode-variable-name-face))
+   ))
+
+(defvar web-mode-blade-font-lock-keywords
+  (append
+   (list
+    '("{{\\|}}" 0 'web-mode-preprocessor-face)
+    '("\\(@\\)\\([[:alpha:]_]+\\)"
+      (1 'web-mode-preprocessor-face)
+      (2 'web-mode-block-control-face)))
+   web-mode-php-font-lock-keywords))
+
+(defvar web-mode-syntax-table
+  (let ((table (make-syntax-table)))
+    (modify-syntax-entry ?_ "w" table)
+    table)
+  "Syntax table in use in web-mode buffers.")
+
+(defvar web-mode-map
+  (let ((map (make-sparse-keymap)))
+
+    (define-key map [menu-bar wm] (cons "Web-Mode" (make-sparse-keymap)))
+    (define-key map [menu-bar wm blk] (cons "Block" (make-sparse-keymap)))
+    (define-key map [menu-bar wm tag] (cons "Html Tag" (make-sparse-keymap)))
+    (define-key map [menu-bar wm elt] (cons "Html Element" (make-sparse-keymap)))
+
+    (define-key map [menu-bar wm sep-1] '(menu-item "--"))
+    (define-key map [menu-bar wm blk blk-next] '(menu-item "Next" web-mode-block-next))
+    (define-key map [menu-bar wm blk blk-prev] '(menu-item "Previous" web-mode-block-previous))
+    (define-key map [menu-bar wm blk blk-end] '(menu-item "End" web-mode-block-beginning))
+    (define-key map [menu-bar wm blk blk-beg] '(menu-item "Beginning" web-mode-block-beginning))
+    (define-key map [menu-bar wm tag tag-sel] '(menu-item "Select" web-mode-tag-select))
+    (define-key map [menu-bar wm tag tag-match] '(menu-item "Match" web-mode-tag-match))
+    (define-key map [menu-bar wm tag tag-next] '(menu-item "Next" web-mode-tag-next))
+    (define-key map [menu-bar wm tag tag-prev] '(menu-item "Previous" web-mode-tag-previous))
+    (define-key map [menu-bar wm tag tag-end] '(menu-item "End" web-mode-tag-beginning))
+    (define-key map [menu-bar wm tag tag-beg] '(menu-item "Beginning" web-mode-tag-beginning))
+    (define-key map [menu-bar wm elt elt-in] '(menu-item "Inner Content" web-mode-element-content-select))
+    (define-key map [menu-bar wm elt elt-parent] '(menu-item "Parent" web-mode-element-parent))
+    (define-key map [menu-bar wm elt elt-sel] '(menu-item "Select" web-mode-element-select))
+    (define-key map [menu-bar wm elt elt-ren] '(menu-item "Rename" web-mode-element-rename))
+    (define-key map [menu-bar wm elt elt-dup] '(menu-item "Clone" web-mode-element-clone))
+    (define-key map [menu-bar wm elt elt-close] '(menu-item "Close" web-mode-element-close))
+    (define-key map [menu-bar wm elt elt-trav] '(menu-item "Traverse DOM" web-mode-element-traverse))
+    (define-key map [menu-bar wm elt elt-child] '(menu-item "Child" web-mode-element-child))
+    (define-key map [menu-bar wm elt elt-del] '(menu-item "Delete" web-mode-element-delete))
+    (define-key map [menu-bar wm elt elt-next] '(menu-item "Next" web-mode-element-next))
+    (define-key map [menu-bar wm elt elt-prev] '(menu-item "Previous" web-mode-element-previous))
+    (define-key map [menu-bar wm elt elt-end] '(menu-item "End" web-mode-element-end))
+    (define-key map [menu-bar wm elt elt-beg] '(menu-item "Beginning" web-mode-element-beginning))
+    (define-key map [menu-bar wm err] '(menu-item "Show error(s)" web-mode-errors-show))
+    (define-key map [menu-bar wm fold] '(menu-item "Fold/Unfold" web-mode-fold-or-unfold))
+    (define-key map [menu-bar wm indent] '(menu-item "Indent buffer" web-mode-buffer-indent))
+    (define-key map [menu-bar wm nav] '(menu-item "Tag/Block navigation" web-mode-tag-match))
+    (define-key map [menu-bar wm expand] '(menu-item "Mark and Expand" web-mode-mark-and-expand))
+    (define-key map [menu-bar wm space] '(menu-item "Toggle whitespaces" web-mode-whitespaces-show))
+    (define-key map [menu-bar wm xpath] '(menu-item "XPath" web-mode-xpath))
+    (define-key map [menu-bar wm snippet] '(menu-item "Insert snippet" web-mode-snippet-insert))
+    (define-key map [menu-bar wm entities] '(menu-item "Replace HTML entities" web-mode-entities-replace))
+
+    (define-key map (kbd "C-;")       'web-mode-comment-or-uncomment)
+    (define-key map (kbd "M-;")       'web-mode-comment-or-uncomment)
+
+    (define-key map (kbd "C-c C-d")   'web-mode-errors-show)
+    (define-key map (kbd "C-c C-f")   'web-mode-fold-or-unfold)
+    (define-key map (kbd "C-c C-i")   'web-mode-buffer-indent)
+    (define-key map (kbd "C-c C-m")   'web-mode-mark-and-expand)
+    (define-key map (kbd "C-c C-n")   'web-mode-tag-match)
+    (define-key map (kbd "C-c C-r")   'web-mode-entities-replace)
+    (define-key map (kbd "C-c C-s")   'web-mode-snippet-insert)
+    (define-key map (kbd "C-c C-x")   'web-mode-xpath)
+    (define-key map (kbd "C-c C-w")   'web-mode-whitespaces-show)
+
+    (define-key map (kbd "C-c /")     'web-mode-element-close)
+    (define-key map (kbd "C-c <")     'web-mode-element-beginning)
+    (define-key map (kbd "C-c >")     'web-mode-element-end)
+
+    (define-key map (kbd "C-c C-b b") 'web-mode-block-beginning)
+    (define-key map (kbd "C-c C-b e") 'web-mode-block-end)
+    (define-key map (kbd "C-c C-b n") 'web-mode-block-next)
+    (define-key map (kbd "C-c C-b p") 'web-mode-block-previous)
+
+    (define-key map (kbd "C-c C-e b") 'web-mode-element-beginning)
+    (define-key map (kbd "C-c C-e c") 'web-mode-element-clone)
+    (define-key map (kbd "C-c C-e d") 'web-mode-element-child)
+    (define-key map (kbd "C-c C-e e") 'web-mode-element-end)
+    (define-key map (kbd "C-c C-e i") 'web-mode-element-content-select)
+    (define-key map (kbd "C-c C-e k") 'web-mode-element-delete)
+    (define-key map (kbd "C-c C-e n") 'web-mode-element-next)
+    (define-key map (kbd "C-c C-e p") 'web-mode-element-previous)
+    (define-key map (kbd "C-c C-e r") 'web-mode-element-rename)
+    (define-key map (kbd "C-c C-e s") 'web-mode-element-select)
+    (define-key map (kbd "C-c C-e t") 'web-mode-element-traverse)
+    (define-key map (kbd "C-c C-e u") 'web-mode-element-parent)
+
+    (define-key map (kbd "C-c C-t b") 'web-mode-tag-beginning)
+    (define-key map (kbd "C-c C-t e") 'web-mode-tag-end)
+    (define-key map (kbd "C-c C-t m") 'web-mode-tag-match)
+    (define-key map (kbd "C-c C-t n") 'web-mode-tag-next)
+    (define-key map (kbd "C-c C-t p") 'web-mode-tag-previous)
+    (define-key map (kbd "C-c C-t s") 'web-mode-tag-select)
+
+    ;; compatibility with nxml
+    (define-key map (kbd "M-C-u")     'web-mode-element-parent)
+    (define-key map (kbd "M-C-d")     'web-mode-element-child)
+    (define-key map (kbd "M-C-n")     'web-mode-element-next)
+    (define-key map (kbd "M-C-p")     'web-mode-element-previous)
+
+    map)
+  "Keymap for `web-mode'.")
+
+;;--- compatibility
+
+(eval-and-compile
+
+  (defalias 'web-mode-prog-mode
+    (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
+
+  (if (fboundp 'with-silent-modifications)
+      (defalias 'web-mode-with-silent-modifications 'with-silent-modifications)
+    (defmacro web-mode-with-silent-modifications (&rest body)
+      "For compatibility with Emacs pre 23.3"
+      `(let ((old-modified-p (buffer-modified-p))
+             (inhibit-modification-hooks t)
+             (buffer-undo-list t))
+         (unwind-protect
+             ,@body
+           (set-buffer-modified-p old-modified-p)))))
+
+  );eval-and-compile
+
+;;;###autoload
+(define-derived-mode web-mode web-mode-prog-mode "Web"
+  "Major mode for editing web templates."
+
+  (make-local-variable 'after-change-functions)
+  (make-local-variable 'font-lock-fontify-buffer-function)
+  (make-local-variable 'font-lock-keywords)
+  (make-local-variable 'font-lock-multiline)
+  (make-local-variable 'font-lock-unfontify-buffer-function)
+  (make-local-variable 'forward-sexp-function)
+  (make-local-variable 'imenu-case-fold-search)
+  (make-local-variable 'imenu-create-index-function)
+  (make-local-variable 'imenu-generic-expression)
+  (make-local-variable 'indent-line-function)
+  (make-local-variable 'indent-tabs-mode)
+  (make-local-variable 'require-final-newline)
+
+  (make-local-variable 'web-mode-buffer-highlighted)
+  (make-local-variable 'web-mode-comment-style)
+  (make-local-variable 'web-mode-content-type)
+  (make-local-variable 'web-mode-display-table)
+  (make-local-variable 'web-mode-engine)
+  (make-local-variable 'web-mode-block-regexps)
+  (make-local-variable 'web-mode-engine-file-regexps)
+  (make-local-variable 'web-mode-expand-initial-pos)
+  (make-local-variable 'web-mode-expand-previous-state)
+  (make-local-variable 'web-mode-hl-line-mode-flag)
+  (make-local-variable 'web-mode-indent-style)
+  (make-local-variable 'web-mode-is-narrowed)
+  (make-local-variable 'web-mode-block-regexp)
+  (make-local-variable 'web-mode-time)
+
+  (if (and (fboundp 'global-hl-line-mode)
+           global-hl-line-mode)
+      (setq web-mode-hl-line-mode-flag t))
+
+  (setq fill-paragraph-function 'web-mode-fill-paragraph
+        font-lock-fontify-buffer-function 'web-mode-scan-buffer
+        forward-sexp-function 'web-mode-forward-sexp
+        ;;          font-lock-keywords-only t
+        font-lock-unfontify-buffer-function 'web-mode-scan-buffer
+        imenu-case-fold-search t
+        imenu-create-index-function 'web-mode-imenu-index
+        indent-line-function 'web-mode-indent-line
+        indent-tabs-mode nil
+        require-final-newline nil)
+
+  (remove-hook 'after-change-functions 'font-lock-after-change-function t)
+
+  (add-hook 'after-change-functions 'web-mode-on-after-change t t)
+
+  (add-hook 'after-save-hook
+            '(lambda ()
+               (when web-mode-is-scratch
+                 (web-mode-guess-engine-and-content-type)
+                 (web-mode-scan-buffer)
+;;                 (message "-->%S" (buffer-file-name))
+                 )
+               nil)
+            t t)
+
+  (when (boundp 'yas-after-exit-snippet-hook)
+    (add-hook 'yas-after-exit-snippet-hook
+              '(lambda () (web-mode-buffer-refresh))
+              t t)
+    )
+
+  (when web-mode-enable-whitespaces
+    (web-mode-whitespaces-on))
+
+  (web-mode-guess-engine-and-content-type)
+  (web-mode-scan-buffer)
+
+  )
+
+(defun web-mode-forward-sexp (&optional arg)
+  "Move forward."
+  (interactive "p")
+  (unless arg (setq arg 1))
+  (cond
+   ((> arg 0)
+    (while
+        (progn
+          (web-mode-tag-next)
+          (> (setq arg (1- arg)) 0))))
+   ((< arg 0)
+    (while
+        (progn
+          (web-mode-tag-previous)
+          (< (setq arg (1+ arg)) 0))))
+   ))
+
+(defun web-mode-guess-engine-and-content-type ()
+  "Try to guess the server engine and the content type."
+  (let (buff-name elt found)
+
+    (setq buff-name (buffer-file-name))
+    (unless buff-name (setq buff-name (buffer-name)))
+
+    (setq web-mode-is-scratch (string= buff-name "*scratch*"))
+
+    (setq web-mode-content-type nil)
+
+    (when (boundp 'web-mode-content-types-alist)
+      (setq found nil)
+      (dolist (elt web-mode-content-types-alist)
+        (when (and (not found) (string-match-p (cdr elt) buff-name))
+          (setq web-mode-content-type (car elt)
+                found t))
+        )
+      )
+
+    (unless web-mode-content-type
+      (setq found nil)
+      (dolist (elt web-mode-content-types)
+        (when (and (not found) (string-match-p (cdr elt) buff-name))
+          (setq web-mode-content-type (car elt)
+                found t))
+        )
+      )
+
+    (when (boundp 'web-mode-engines-alist)
+      (setq found nil)
+      (dolist (elt web-mode-engines-alist)
+        (when (string-match-p (cdr elt) buff-name)
+          (setq web-mode-engine (car elt)))
+        )
+      )
+
+    (unless web-mode-engine
+      (setq found nil)
+      (dolist (elt web-mode-engine-file-regexps)
+        (when (and (not found) (string-match-p (cdr elt) buff-name))
+          (setq web-mode-engine (car elt)
+                found t))
+        )
+      )
+
+    (when web-mode-engine
+      (setq found nil)
+      (dolist (elt web-mode-engine-families)
+        (when (and (not found) (member web-mode-engine (cdr elt)))
+          (setq web-mode-engine (car elt)
+                found t))
+        )
+      )
+
+    (setq elt (assoc web-mode-engine web-mode-block-regexps))
+    (if elt
+        (setq web-mode-block-regexp (cdr elt))
+      (setq web-mode-engine "none")
+      )
+
+;;    (message "buffer=%S engine=%S type=%S regexp=%S"
+;;             buff-name web-mode-engine web-mode-content-type web-mode-block-regexp)
+
+    (when (string= web-mode-engine "razor")
+      (setq web-mode-enable-block-face t))
+
+    (when (and (string= web-mode-content-type "html")
+               (not (string= web-mode-engine "none")))
+      (setq web-mode-active-block-regexp
+            (cdr (assoc web-mode-engine web-mode-active-block-regexps)))
+      (setq web-mode-close-block-regexp
+            (cdr (assoc web-mode-engine web-mode-close-block-regexps)))
+      (setq web-mode-engine-control-matcher
+            (intern-soft (concat "web-mode-match-" web-mode-engine "-block")))
+;;      (message "%S\n%S\n%S" web-mode-active-block-regexp web-mode-close-block-regexp web-mode-engine-control-matcher)
+      )
+
+    ))
+
+(defun web-mode-imenu-index ()
+  "Return a table of contents."
+  (let (toc-index)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward "<h\\([1-9]\\)\\([^>]*\\)>\\([^<]*\\)" nil t)
+	(setq toc-index
+	      (cons (cons (concat (make-string
+				   (* 2 (1- (string-to-number (match-string 1))))
+				   ?\s)
+				  (match-string 3))
+			  (line-beginning-position))
+		    toc-index))))
+    (nreverse toc-index)))
+
+(defun web-mode-scan-buffer ()
+  "Scan entine buffer."
+  (interactive)
+  (web-mode-scan-region (point-min) (point-max)))
+
+(defun web-mode-scan-region (beg end &optional verbose)
+  "Identify code blocks (client/server) and syntactic symbols (strings/comments)."
+  (interactive)
+  (web-mode-trace "scanning region")
+  ;;  (message "scanning buffer from %d to %d" beg end)
+  (web-mode-with-silent-modifications
+   (save-excursion
+     (save-restriction
+       (save-match-data
+         (let ((inhibit-modification-hooks t)
+               (inhibit-point-motion-hooks t)
+               (inhibit-quit t))
+           (setq beg (if web-mode-is-narrowed 1 beg))
+           (remove-text-properties beg end web-mode-text-properties)
+           (cond
+            ((member web-mode-content-type '("javascript" "json" "css"))
+             (web-mode-scan-part beg end web-mode-content-type))
+            ((string= web-mode-engine "none")
+             (web-mode-scan-parts beg end)
+             (web-mode-trace "parts scanned")
+             )
+            (t
+             (web-mode-mark-blocks beg end)
+             (web-mode-trace "blocks marked")
+             (web-mode-scan-parts beg end)
+             (web-mode-trace "parts scanned")
+             (web-mode-scan-blocks beg end)
+             (web-mode-trace "blocks scanned")
+             )
+            );cond
+           (if web-mode-enable-whitespaces
+               (web-mode-scan-whitespaces beg end))
+           ))))))
+
+(defun web-mode-mark-blocks (beg end)
+  "Identifies blocks (with block-side, block-beg, block-end text properties)."
+  (save-excursion
+
+    (let ((i 0)
+          open close closing-string start sub1 sub2 sub3 pos tagopen l tmp)
+
+      (goto-char beg)
+
+      ;;      (message "%S: %Sx%S" (point) beg end)
+      ;;      (message "regexp=%S" web-mode-block-regexp)
+      (while (and (< i 500)
+                  (> end (point))
+                  (re-search-forward web-mode-block-regexp end t))
+
+        (setq i (1+ i)
+              closing-string nil
+              close nil
+              tagopen (match-string 0)
+              open (match-beginning 0)
+              pos nil)
+
+        (when (member (string-to-char tagopen) '(?\s ?\t))
+          (setq l (length tagopen))
+          (setq tagopen (replace-regexp-in-string "\\`[ \t]*" "" tagopen))
+          (setq open (+ open (- l (length tagopen))))
+          )
+
+        (setq sub1 (substring tagopen 0 1))
+        (setq sub2 (substring tagopen 0 2))
+
+        (cond
+
+         ((string= web-mode-engine "php")
+          (unless (looking-at-p "xml ")
+            (setq closing-string '("<\\?". "\\?>"))
+            )
+          );php
+
+         ((string= web-mode-engine "django")
+          (cond
+           ((string= sub2 "{{")
+            (setq closing-string "}}"))
+           ((string= sub2 "{%")
+            (setq closing-string "%}"))
+           (t
+            (setq closing-string "#}"))
+           )
+          );django
+
+         ((string= web-mode-engine "ctemplate")
+          (setq closing-string "}}")
+          );ctemplate
+
+         ((or (string= web-mode-engine "asp")
+              (string= web-mode-engine "aspx"))
+          (setq closing-string "%>")
+          );asp
+
+         ((string= web-mode-engine "blade")
+          (cond
+           ((string= sub2 "{{")
+            (setq closing-string "}}"))
+           ((string= sub1 "@")
+            (setq closing-string "EOL"))
+           )
+          );blade
+
+         ((string= web-mode-engine "smarty")
+          (cond
+           ((string= sub2 "{*")
+            (setq closing-string "*}"))
+           ((string= sub2 "{#")
+            (setq closing-string "#}"))
+           (t
+            (setq closing-string "}"))
+           )
+          );smarty
+
+         ((string= web-mode-engine "dust")
+          (cond
+           ((string= sub2 "{!")
+            (setq closing-string "!}"))
+           (t
+            (setq closing-string "}")
+            )
+           )
+          );dust
+
+         ((string= web-mode-engine "closure")
+          (cond
+           ((string= sub2 "//")
+            (setq closing-string "EOL")
+            )
+           ((string= sub2 "/*")
+            (setq closing-string "*/")
+            )
+           (t
+            (setq closing-string "}")
+            )
+           )
+          );closure
+
+         ((string= web-mode-engine "ctemplate")
+          (cond
+           ((string= sub3 "{{{")
+            (setq closing-string "}}}"))
+           (t
+            (setq closing-string "}}"))
+           )
+          );ctemplate
+
+         ((string= web-mode-engine "go")
+          (setq closing-string "}}")
+          );go
+
+         ((string= web-mode-engine "erb")
+          (cond
+           ((string= sub2 "<%")
+            (setq closing-string "%>"))
+           (t
+            (setq closing-string "EOL"))
+           )
+          );erb
+
+         ((string= web-mode-engine "jsp")
+          (cond
+           ((string= sub2 "<%")
+            (setq closing-string "%>"))
+           ((string= sub2 "${")
+            (setq closing-string "}"))
+           (t
+            (setq closing-string ">"))
+           )
+          );jsp
+
+         ((string= web-mode-engine "freemarker")
+          (cond
+           ((string= sub1 "<")
+            (setq closing-string ">"))
+           ((string= sub1 "[")
+            (setq closing-string "]"))
+           (t
+            (setq closing-string "}"))
+           )
+          );freemarker
+
+         ((string= web-mode-engine "velocity")
+          (cond
+           ((string= sub2 "##")
+            (setq closing-string "EOL"))
+           ((string= sub2 "#*")
+            (setq closing-string "*#"))
+           (t
+            (setq closing-string "EOV"))
+           )
+          );velocity
+
+         ((string= web-mode-engine "razor")
+          (cond
+           ((string= sub2 "@@")
+            (forward-char 2)
+            (setq closing-string nil))
+           ((string= sub2 "@*")
+            (setq closing-string "*@"))
+           ((string= sub1 "@")
+            (setq closing-string "EOR"))
+           ((string= sub1 "}")
+            (setq closing-string "EOR"))
+           )
+          );razor
+
+         ((string= web-mode-engine "python")
+          (unless (looking-at-p "xml ")
+            (setq closing-string "?>"))
+          );python
+
+         );cond
+
+        (when closing-string
+
+          (cond
+
+           ((listp closing-string)
+            (if (web-mode-rsf-balanced (car closing-string) (cdr closing-string) end t)
+                (progn
+                  (setq close (match-end 0)
+                        pos (point))
+                  )
+              (when (string= "<?" sub2)
+                (setq close (point-max)
+                      pos (point-max)))
+              )
+            )
+
+           ((and (member web-mode-engine '("closure" "dust" "smarty"))
+                 (string= closing-string "}"))
+            (goto-char open)
+            (setq tmp (web-mode-closing-paren-position (point) (line-end-position)))
+            (if tmp
+                (setq tmp (1+ tmp))
+              (setq tmp (line-end-position)))
+            (goto-char tmp)
+            (setq close (point)
+                  pos (point))
+            )
+
+           ((string= closing-string "EOL")
+            (end-of-line)
+            (setq close (point)
+                  pos (point)))
+
+           ((string= closing-string "EOR")
+            (web-mode-razor-skip-forward open)
+            (setq close (point)
+                  pos (point)))
+
+           ((string= closing-string "EOV")
+            (web-mode-velocity-skip-forward open)
+            (setq close (point)
+                  pos (point)))
+
+           ((search-forward closing-string end t)
+            (setq close (match-end 0)
+                  pos (point)))
+
+           );cond
+
+          (when (and close (>= end pos))
+            ;;            (message "pos(%S) : open(%S) close(%S)" pos open close)
+            (add-text-properties open close '(block-side t))
+            (put-text-property open (1+ open) 'block-beg t)
+            (put-text-property (1- close) close 'block-end t)
+            )
+
+          (if pos (goto-char pos))
+
+          );when closing-string
+
+        );while
+
+      (when (>= i 500)
+        (message "** strange loop (web-mode-mark-blocks) **"))
+
+      )))
+
+(defun web-mode-scan-blocks (region-beg region-end)
+  "Fontify blocks. The scan relies on the 'block-beg text property."
+  (let ((i 0)
+        (beg region-beg)
+        (end nil)
+        (continue t))
+    (while continue
+      (setq end nil
+            i (1+ i))
+      (unless (get-text-property beg 'block-beg)
+        (setq beg (web-mode-block-next-position beg)))
+      (when (and beg (< beg region-end))
+        (setq end (web-mode-block-end-position beg)))
+      (cond
+       ((or (null end)
+            (> end region-end)
+            (> i 200))
+        (setq continue nil)
+        (if (> i 200) (message "*** invalid loop (web-mode-scan-blocks) ***")))
+       (t
+        (setq end (1+ end))
+        ;;(message "beg=%S end=%S" beg end)
+        (web-mode-scan-block beg end)
+        (when (and (member web-mode-engine '("jsp"))
+                   (> (- end beg) 12)
+                   (char-equal ?\< (char-after beg)))
+          (web-mode-scan-jsp-tag beg end))
+        (setq beg end)
+        )
+       );cond
+      );while
+    ))
+
+(defun web-mode-scan-block (beg end)
+  "Fontify a block."
+  (let (sub1 sub2 sub3 regexp props start ms continue fc keywords tag token-type hddeb hdend hdflk)
+
+    (goto-char beg)
+
+    (setq sub1 (buffer-substring-no-properties beg (+ beg 1))
+          sub2 (buffer-substring-no-properties beg (+ beg 2)))
+    (setq sub3 sub2)
+    (if (>= (point-max) (+ beg 3))
+        (setq sub3 (buffer-substring-no-properties beg (+ beg 3))))
+
+    (cond
+
+     ((string= web-mode-engine "php")
+      (setq regexp "//\\|/\\*\\|\"\\|'\\|<<<['\"]?\\([[:alnum:]]+\\)['\"]?"
+            props '(face nil)
+            keywords web-mode-php-font-lock-keywords)
+      );php
+
+     ((string= web-mode-engine "django")
+      (cond
+       ((string= sub2 "{{")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-django-expr-font-lock-keywords)
+        )
+       ((string= sub2 "{%")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-django-code-font-lock-keywords)
+        )
+       ((string= sub2 "{#")
+        (setq props '(block-token comment face web-mode-comment-face))
+        )
+       )
+      );django
+
+     ((string= web-mode-engine "ctemplate")
+      (cond
+       ((string= sub3 "{{!")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       ((string= sub3 "{{%")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-ctemplate-font-lock-keywords))
+       (t
+        (setq props '(face nil)
+              keywords web-mode-ctemplate-font-lock-keywords))
+       )
+      );ctemplate
+
+     ((string= web-mode-engine "go")
+      (cond
+       ((string= sub3 "{{/")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       ((string= sub2 "{{")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-go-font-lock-keywords))
+       )
+      );go
+
+     ((string= web-mode-engine "razor")
+      (cond
+       ((string= sub2 "@*")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       (t
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-razor-font-lock-keywords))
+       )
+      );razor
+
+     ((string= web-mode-engine "python")
+      (setq regexp "\"\\|'\\|#"
+            props '(face nil)
+            keywords web-mode-python-font-lock-keywords)
+      );python
+
+     ((string= web-mode-engine "blade")
+      (cond
+       ((string= sub3 "{{-")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       (t
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-blade-font-lock-keywords))
+       )
+      );blade
+
+     ((string= web-mode-engine "velocity")
+      (cond
+       ((member sub2 '("##" "#*"))
+        (setq props '(block-token comment face web-mode-comment-face)))
+       ((string= sub1 "$")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-velocity-font-lock-keywords))
+       ((string= sub1 "#")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-velocity-font-lock-keywords))
+       )
+      );velocity
+
+     ((string= web-mode-engine "jsp")
+      (cond
+       ((string= sub3 "<%-")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       ((string= sub3 "<%@")
+        (setq regexp "/\\*"
+              props '(face nil)
+              keywords web-mode-directive-font-lock-keywords))
+       ((member sub2 '("${" "#{"))
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-uel-font-lock-keywords))
+       ((string= sub2 "<%")
+        (setq regexp "//\\|/\\*\\|\"\\|'"
+              props '(face nil)
+              keywords web-mode-jsp-font-lock-keywords))
+       (t
+        (setq props '(face nil)
+              keywords web-mode-jsp-tag-font-lock-keywords)
+        )
+       )
+      );jsp
+
+     ((string= web-mode-engine "freemarker")
+      (cond
+       ((member sub3 '("<#-" "[#-"))
+        (setq props '(block-token comment face web-mode-comment-face))
+        )
+       ((member sub2 '("${" "#{"))
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-uel-font-lock-keywords))
+       ((or (member sub2 '("<@" "[@" "<#" "[#"))
+            (member sub3 '("</@" "[/@" "</#" "[/#")))
+        (setq regexp "\""
+              props '(face nil)
+              keywords (if (char-equal ?\[ (aref sub2 0))
+                           web-mode-freemarker-square-font-lock-keywords
+                         web-mode-freemarker-font-lock-keywords))
+        )
+       (t
+        (setq props '(face nil)
+              keywords web-mode-jsp-tag-font-lock-keywords)
+        )
+       )
+      );freemarker
+
+     ((string= web-mode-engine "erb")
+      (cond
+       ((string= sub3 "<%#")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       (t
+        (setq regexp "\"\\|'\\|#"
+              props '(face nil)
+              keywords web-mode-erb-font-lock-keywords)
+        )
+       )
+      );erb
+
+     ((string= web-mode-engine "asp")
+      (setq regexp "//\\|/\\*\\|\"\\|'"
+            props '(face nil)
+            keywords web-mode-asp-font-lock-keywords)
+      );asp
+
+     ((string= web-mode-engine "aspx")
+      (cond
+       ((string= sub3 "<%-")
+        (setq props '(block-token comment face web-mode-comment-face)))
+       ((string= sub3 "<%@")
+        (setq regexp "/\\*"
+              props '(face nil)
+              keywords web-mode-directive-font-lock-keywords))
+       ((string= sub3 "<%$")
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-expression-font-lock-keywords))
+       (t
+        (setq regexp "//\\|/\\*\\|\"\\|'"
+              props '(face nil)
+              keywords web-mode-aspx-font-lock-keywords)
+        )
+       )
+      );aspx
+
+     ((string= web-mode-engine "smarty")
+      (cond
+       ((string= sub2 "{*")
+        (setq props '(block-token comment face web-mode-comment-face))
+        )
+       (t
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-smarty-font-lock-keywords)
+        )
+       )
+      );smarty
+
+     ((string= web-mode-engine "dust")
+      (cond
+       ((string= sub2 "{!")
+        (setq props '(block-token comment face web-mode-comment-face))
+        )
+       (t
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-dust-font-lock-keywords)
+        )
+       )
+      );dust
+
+     ((string= web-mode-engine "closure")
+      (cond
+       ((member sub2 '("/*" "//"))
+        (setq props '(block-token comment face web-mode-comment-face))
+        )
+       (t
+        (setq regexp "\"\\|'"
+              props '(face nil)
+              keywords web-mode-closure-font-lock-keywords)
+        )
+       )
+      );closure
+
+     )
+
+    (add-text-properties beg end props)
+
+    (when keywords (web-mode-fontify-region beg end keywords))
+
+    (when regexp
+      (setq token-type "string")
+      (goto-char beg)
+      (while (re-search-forward regexp end t)
+        (setq start (match-beginning 0)
+              ms (match-string 0)
+              continue t)
+        (setq fc (substring ms 0 1))
+        (cond
+
+         ((and (string= web-mode-engine "asp")
+               (string= fc "'"))
+          (setq props '(block-token comment face web-mode-block-comment-face)
+                token-type "comment")
+          (goto-char (if (< end (line-end-position)) end (line-end-position)))
+          )
+
+         ((string= fc "'")
+          (setq props '(block-token string face web-mode-block-string-face))
+          (while (and continue (search-forward "'" end t))
+            (setq continue (char-equal ?\\ (char-before (- (point) 1))))
+            )
+          )
+
+         ((string= fc "\"")
+          (setq props '(block-token string face web-mode-block-string-face))
+          (while (and continue (search-forward "\"" end t))
+            (setq continue (char-equal ?\\ (char-before (- (point) 1))))
+            )
+          )
+
+         ((string= ms "//")
+          (setq props '(block-token comment face web-mode-block-comment-face)
+                token-type "comment")
+          (goto-char (if (< end (line-end-position)) end (line-end-position)))
+          )