           (while not-indented
             ;; Check that we are inside open brackets
             (save-excursion
-              (let ((cur-depth (factor-brackets-depth)))
+              (let ((cur-depth (factor--brackets-depth)))
                 (forward-line -1)
                 (setq cur-indent (+ (current-indentation)
                                     (* factor-indent-width
-                                       (- cur-depth (factor-brackets-depth)))))
+                                       (- cur-depth (factor--brackets-depth)))))
                 (setq not-indented nil)))
             (forward-line -1)
               ;; Check that we are after the end of previous word


(add-to-list 'auto-mode-alist '("\\.factor\\'" . factor-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; factor-listener-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-derived-mode factor-listener-mode comint-mode "Factor Listener")


                      (setq not-indented nil))))))))
    cur-indent))

(defun factor-indent-line ()
  "Indent current line as Factor code"
  (let ((target (factor--calculate-indentation))
        (pos (- (point-max) (point))))
    (if (= target (current-indentation))
        (if (< (current-column) (current-indentation))
