 ;;:type:
   ;; One of: integer, number, string, regexp, character, hook,
   ;;         symbol, function, variable, boolean
+
+
+(defcustom ee-mode-hook nil
+  "*Hook called by `ee-mode'.
+{jpw: 10/05}"
+  :type 'hook
+  :group 'ee-mode)
 
 
 (defcustom ee-mode-block-indent 4

(defconst ee-mode-expr-closing-quote-re "\"[,\;]\\s *$")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Mode Definition
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define-generic-mode 'ee-generic-mode
  ;; Adding "! ... \n" to the syntax table as comment-start/comment-end screws
  ;; up font-lock w/ the != operator.  So, we need a workaround; see below.
  (list "!" "\n")
  ee-mode-keyword-list
  (list
   (list
    "\\(XRef\\w+\\$\\)" 
    '(1 'ee-mode-map-function-face prepend))
   (list
    ee-mode-language-fn-re
    '(1 'ee-mode-language-function-face prepend))
   (list
    "\\({\\(double\\|int\\|string\\)}\\)" 
    '(1 'font-lock-type-face prepend))
   (list
    "\\(\\.\\([bfi][0-9]+\\|[cs]\\)\\)" 
    '(1 'font-lock-type-face prepend))
   (list
    "#include"
    '(0 'font-lock-constant-face prepend))
   (list
    ee-mode-globals-re
    '(1 'ee-mode-globals-face prepend))
   (list
    ee-mode-var-re
    '(1 'font-lock-variable-name-face prepend)
    '(2 'font-lock-type-face prepend))
   ;;
   ;; Optional font-locking.  Right now, controlled by commenting out. :P
   ;;
   (list
    "\\([;,]\\)\\s *$"
    '(1 'ee-mode-syntactic-punctuation-face prepend))
   (list
    "^\\s *\\(,\\)\\s *$"
    '(1 'ee-mode-syntactic-punctuation-face prepend))
   ;;
   ;; Does definition ordering matter for FontLock?  If so, these must come
   ;; last.
   ;;
   (list ee-mode-comment-re '(1 'font-lock-comment-face t))
   (list
    "[^!']*\\('[^\\\\']*\\(\\\\.[^\\\\']*\\)*'\\)"
    '(1 'font-lock-string-face append))
   )
  (list "\\.cfg\\'" "\\.templt\\'")
  (list 'generic-ee-mode-setup-function)
  "Generic Mode for ExpressionEvaluator files.")


(defun generic-ee-mode-setup-function ()
  (make-local-variable 'ee-mode-syntax-table)
  (setq ee-mode-syntax-table (copy-syntax-table))
  (modify-syntax-entry ?_  "w" ee-mode-syntax-table)
  (modify-syntax-entry ?_  "w" ee-mode-syntax-table)
  (modify-syntax-entry ?'  "$" ee-mode-syntax-table)
  (modify-syntax-entry ?\" "$" ee-mode-syntax-table)
  (modify-syntax-entry ?\\ "\\" ee-mode-syntax-table)

  (make-local-variable 'font-lock-multiline)
  (make-local-variable 'font-lock-support-mode)
  (make-local-variable 'lazy-lock-minimum-size)
  (make-local-variable 'jit-lock-stealth-time)
  (make-local-variable 'jit-lock-stealth-nice)
  (make-local-variable 'jit-lock-defer-contextually)
  (make-local-variable 'lazy-lock-defer-contextually)
  (setq font-lock-multiline t
        ;; `jit-lock-mode' doesn't correctly fontify everything we want it to.
        ;; 
        ;; `fast-lock-mode' and `lazy-lock-mode' require you to
        ;; manually-refontify when editing text in some of the more complex
        ;; multiline expressions.  `fast-lock-mode' works by keeping a cache
        ;; of fontifications.
        jit-lock-stealth-time  3
        jit-lock-stealth-nice  0.1
        ;; Remove contextual deferment from all of the modes.  Permits
        ;; in-place fontification & preserves font of subsequent text, which
        ;; is useful for multiline syntactic contexts.
        jit-lock-defer-contextually  nil
        lazy-lock-defer-contextually  nil)

  ;; The `define-generic-mode' defun sets up the syntax table and sets
  ;; `comment-start' and `comment-end'.  We only need to add the following:
  (make-local-variable 'comment-start-skip)
  (setq comment-start-skip "!+ *")
  (setq comment-start-skip "![ \t]*")

  ;; Adding "! ... \n" to the syntax table as comment-start/comment-end screws
  ;; up font-lock w/ the != operator.  As a workaround, disable syntactic
  ;; keywords.
  (make-local-variable 'font-lock-syntactic-keywords)
  (setq font-lock-syntactic-keywords 'nil)

  (set-syntax-table ee-mode-syntax-table)
  )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Special Functions
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;

{jpw: 10/05}")
(defconst ee-mode-globals-re
  (eval-when-compile
    (regexp-opt ee-mode-globals-list t)
    ))


(defconst ee-mode-generic-blockdefn-list
