 
 (defun lean-server-handle-modified-buffer ()
   "Handle modified buffer when lean-mode start"
-  (interactive)
-  (when (buffer-file-name)
-    (let* ((current-file-name (buffer-file-name))
-           (current-directory (file-name-directory current-file-name))
-           (temp-prefix (concat (file-name-as-directory current-directory)
-                                "lean-temp"))
-           (temp-file (lean-server-save-buffer-to-temp-file temp-prefix)))
-      (lean-debug "lean-server-handle-modified-buffer: %s => %s"
-                         current-file-name
-                         temp-file)
-      (lean-server-send-cmd-async (lean-cmd-visit temp-file))
-      (setq lean-global-server-current-file-name current-file-name)
-      (lean-server-send-cmd-async (lean-cmd-wait)
-                                  (lambda () (delete-file temp-file))))))
+  (when (buffer-modified-p)
+    (lean-server-send-cmd-async (lean-cmd-sync))))
 
 (provide 'lean-server)

  (let ((current-file-name (or file-name (buffer-file-name))))
    (unless (string= lean-global-server-current-file-name
                     current-file-name)
      (lean-server-visit-current-buffer))))

(defun lean-server-before-send-cmd (cmd)
  "Operations to perform before sending a command."

           do (lean-server-send-cmd-async (lean-cmd-replace n (lean-grab-line n)))
           finally (setq lean-changed-lines nil)))

(defun lean-server-check-current-file (&optional file-name)
  "Check lean-global-server-current-file-name

