 
 (defvar-local merlin--loaded-once nil
   "Set to nil if buffer has not been loaded at least once in merlin.")
-
-;; Overlays
-(defvar-local merlin-lock-zone-highlight-overlay nil
-  "Overlay used for the lock zone highlighting.")
-
-(defvar-local merlin-lock-zone-fringe-overlay nil
-  "Overlay used for the fringe indicator of the lock zone.")
 
 ;; Errors related variables
 (defvar-local merlin-erroneous-buffer nil

;; POINT SYNCHRONIZATION ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun merlin-sync-fringe-lock-zone ()
  "Display the position of the lock zone by a marker in the fringe."
  (if merlin-lock-zone-fringe-overlay
      (delete-overlay merlin-lock-zone-fringe-overlay))
  (save-excursion
    (goto-char merlin--dirty-point)
    (setq merlin-lock-zone-fringe-overlay (make-overlay (point) (point)))
    (merlin-add-display-properties
     merlin-lock-zone-fringe-overlay
     'horizontal-bar
     "-")))

(defun merlin-sync-highlight-lock-zone ()
  "Mark the position of the lock zone by highlighting the zone."
    (if merlin-lock-zone-highlight-overlay
      (delete-overlay merlin-lock-zone-highlight-overlay))
  (setq merlin-lock-zone-highlight-overlay (make-overlay (point-min) merlin--dirty-point))
  (overlay-put merlin-lock-zone-highlight-overlay 'face 'merlin-locked-face))

(defun merlin-sync-lock-zone-display ()
  "Update the locked zone display, according to `merlin-display-lock-zone', ie.
iterates through it and call each method."
  (dolist (x merlin-display-lock-zone)
    (case x
      (fringe (merlin-sync-fringe-lock-zone))
      (highlight (merlin-sync-highlight-lock-zone)))))

(defun merlin-sync-edit (start end length)
  "Retract the locked zone after an edit.
Called when an edit is made by the user."
  (if (and merlin-mode (< start merlin--dirty-point))
      (progn (setq merlin--dirty-point (1- start))
             (merlin-sync-lock-zone-display))))

(defun merlin-sync-to-point (&optional point skip-marker)
  "Makes sure the buffer is synchronized on merlin-side and centered around (point)."
  (merlin--acquire-buffer)
  (unless point (setq point (point)))
  (merlin--tell-to-point point)
  (unless skip-marker
    (merlin-send-cursor-command '(seek marker)))
  (merlin-sync-lock-zone-display))

;;;;;;;;;;;;;;;;;;
;; ERROR REPORT ;;

;; Faces
;;

(defface merlin-type-face
  '((t :inherit caml-types-expr-face))
  "Face for highlighting a typed expr."
