              (with-current-buffer buffer
                (when emdocs-mode
                  (save-excursion
-                   (setq emdocs-is-network-insert t)
+                   (setq-local emdocs-is-network-insert t)
                    (unwind-protect
                        (cond
                         ((string-equal "insert" type)

                        ((string-equal "delete" type)
                         (goto-char cur-point)
                         (delete-char content)))
                     (setq emdocs-is-network-insert nil))))))
            (buffer-contents
             (with-current-buffer buffer
               (when emdocs-mode
                 (let ((prev-point (point)))
                   (setq emdocs-is-network-insert t)
                   (unwind-protect
                       (progn
                         (goto-char (point-min))
                         (erase-buffer)
                         (insert buffer-contents)
                         (goto-char prev-point))
                     (setq emdocs-is-network-insert nil))))))))))

(defun emdocs-client-filter (client sock msg)
  "docstring"

             :buffer_contents ,(with-current-buffer
                                           (emdocs-get-attached-buffer client)
                                         (buffer-string))))
          "\n"))))))

;;; TODO: make resyncing the file a command

(defun emdocs-server-filter (sock msg)
  "docstring"
