 ;; init-file. There is a hook to enable encore-mode for all files
 ;; with extension .enc.
 
-(setq encore-keywords '("and" "async" "await" "by" "class" "chain" "def" "else" "eos" "for" "foreach" "get" "getNext" "if" "in" "let" "liftf" "liftv" "new" "not" "or" "passive" "print" "repeat" "require" "stream" "suspend" "then" "this" "trait" "unless" "val" "while" "yield" ))
+(setq encore-keywords '("and" "async" "await" "by" "class" "chain" "def" "else"
+                        "eos" "for" "foreach" "get" "getNext" "if" "in" "let"
+                        "liftf" "liftv" "new" "not" "or" "passive" "print" "repeat"
+                        "require" "stream" "suspend" "then" "this" "trait" "unless"
+                        "val" "while" "yield" "join"))
 (setq encore-danger-words '("embed" "body" "end"))
 (setq encore-constants '("true" "false" "null"))
 (setq encore-primitives '("int" "string" "void" "bool"))

      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 (string-match "\\<passive\\> .*" 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 "\\<while\\>" 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 "\\<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 "\\W*\\([^;]*\\);" line)
					(match-beginning 1)
				      (if (bobp)
					  0))))))))))))))))))))

(setq encore-checked-line nil)
(make-local-variable 'encore-checked-line)

(defun first-word ()
  ""
  (let* ((current-line (current-line))
         (word-start (string-match "[^ \t]" current-line))
         (word-end (string-match "[^a-zA-Z]" current-line word-start)))
    (substring-no-properties current-line word-start word-end)))

(defun classify-indent (line first)
