   (if (equal first "class")
       0
 
-  (if (equal first "def")
-      (if (string-match "\\<def\\>" line)
-          (match-beginning 0)
-      (if (string-match "\\<passive\\>" line)
-          (+ (match-beginning 0) encore-tab-width)
-      (if (string-match "\\<class\\>" line)
-          (+ (match-beginning 0) encore-tab-width))))
+    (if (equal first "def")
+	(if (string-match "\\<def\\>" line)
+	    (match-beginning 0)
+	  (if (string-match "\\<passive\\>" line)
+	      (+ (match-beginning 0) encore-tab-width)
+	    (if (string-match "\\<class\\>" line)
+		(+ (match-beginning 0) encore-tab-width))))
 
-  (if (string-match "\\<passive\\> .*" line)
-      (+ (match-beginning 0) encore-tab-width)
+      (if (string-match "\\<passive\\> .*" line)
+	  (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<class\\> .*" line)
-      (+ (match-beginning 0) encore-tab-width)
+	(if (string-match "\\<class\\> .*" line)
+	    (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<if\\>.*\\<then\\>.*\\<else\\>" line)
-      (match-beginning 0)
-  (if (string-match "\\<if\\>.*\\<then\\>" line)
-      (if (equal first "else")
-          (match-beginning 0)
-        (+ (match-beginning 0) encore-tab-width))
-  (if (string-match "\\<then\\>" line)
-      (if (equal first "else")
-          (match-beginning 0)
-        (+ (match-beginning 0) encore-tab-width))
-  (if (string-match "\\<if\\>.*" line)
-      (if (or (equal first "then") (equal first "else"))
-          (match-beginning 0)
-        (let ((indent (string-match "[^ \t]" line (+ (match-beginning 0) 2)))) (if indent indent (+ (match-beginning 0) encore-tab-width))))
-  (if (string-match "\\<else\\>.*" line)
-        (+ (match-beginning 0) encore-tab-width)
+	  (if (string-match "\\<if\\>.*\\<then\\>.*\\<else\\>" line)
+	      (match-beginning 0)
+	    (if (string-match "\\<if\\>.*\\<then\\>" line)
+		(if (equal first "else")
+		    (match-beginning 0)
+		  (+ (match-beginning 0) encore-tab-width))
+	      (if (string-match "\\<then\\>" line)
+		  (if (equal first "else")
+		      (match-beginning 0)
+		    (+ (match-beginning 0) encore-tab-width))
+		(if (string-match "\\<if\\>.*" line)
+		    (if (or (equal first "then") (equal first "else"))
+			(match-beginning 0)
+		      (let ((indent (string-match "[^ \t]" line (+ (match-beginning 0) 2)))) (if indent indent (+ (match-beginning 0) encore-tab-width))))
+		  (if (string-match "\\<else\\>.*" line)
+		      (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<while\\>" line)
-      (+ (match-beginning 0) encore-tab-width)
+		    (if (string-match "\\<while\\>" line)
+			(+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<let\\>.*\\<in\\>$" line)
-        (+ (match-beginning 0) encore-tab-width)
+		      (if (string-match "\\<let\\>.*\\<in\\>$" line)
+			  (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<embed\\>.*\\<end\\>" line)
-      (match-beginning 0)
-  (if (string-match "\\<embed\\>" line)
-      (if (equal first "end")
-          (match-beginning 0)
-        (+ (match-beginning 0) encore-tab-width))
+			(if (string-match "\\<embed\\>.*\\<end\\>" line)
+			    (match-beginning 0)
+			  (if (string-match "\\<embed\\>" line)
+			      (if (equal first "end")
+				  (match-beginning 0)
+				(+ (match-beginning 0) encore-tab-width))
 
-  (if (string-match "\\<let\\>\\W*\\(\\w+\\)" line)
-      (if (equal "in" first)
-          (match-beginning 0)
-        (match-beginning 1))
-  (if (string-match "\\<let\\>" line)
-      (if (equal "in" first)
-          (match-beginning 0)
-        (+ (match-beginning 0) encore-tab-width))
-  (if (string-match "\\<in\\>[ \t]*$" line)
-      (+ (match-beginning 0) encore-tab-width)
+			    (if (string-match "\\<let\\>\\W*\\(\\w+\\)" line)
+				(if (equal "in" first)
+				    (match-beginning 0)
+				  (match-beginning 1))
+			      (if (string-match "\\<let\\>" line)
+				  (if (equal "in" first)
+				      (match-beginning 0)
+				    (+ (match-beginning 0) encore-tab-width))
+				(if (string-match "\\<in\\>[ \t]*$" line)
+				    (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\<def\\>" line)
-      (+ (match-beginning 0) encore-tab-width)
+				  (if (string-match "\\<def\\>" line)
+				      (+ (match-beginning 0) encore-tab-width)
 
-  (if (string-match "\\W*\\([^;]*\\);" line)
-      (match-beginning 1)
-  (if (bobp)
-      0))))))))))))))))))))
+				    (if (string-match "\\W*\\([^;]*\\);" line)
+					(match-beginning 1)
+				      (if (bobp)
+					  0))))))))))))))))))))
 
 (setq encore-checked-line nil)
 (make-local-variable 'encore-checked-line)

              (setq encore-last-indent 100))
          (setq encore-last-indent indent)))))
  (if (looking-back "^[ \t]*") (back-to-indentation))
)

(define-derived-mode encore-mode prog-mode
  (setq font-lock-defaults '(encore-font-lock-keywords))
  (setq mode-name "Encore")
  (set (make-local-variable 'indent-line-function) 'encore-indent-line)
)

;; Open "*.enc" in encore-mode
(add-to-list 'auto-mode-alist '("\\.enc\\'" . encore-mode))

(provide 'encore-mode)

;; init-file. There is a hook to enable encore-mode for all files
;; with extension .enc.

(setq encore-keywords '("class" "def" "else" "get" "if" "in" "let" "new" "passive" "print" "then" "unless" "while"))
(setq encore-danger-words '("embed" "end"))
(setq encore-constants '("true" "false" "null"))
(setq encore-primitives '("int" "string" "void" "bool"))
