                          (delete-char content)))
                      (setq emdocs-is-network-insert nil))))))
             (buffer-contents
-             (with-current-buffer (emdocs-get-attached-buffer client)
+             (with-current-buffer buffer
                (when emdocs-mode
                  (let ((prev-point (point)))
                    (setq emdocs-is-network-insert t)

       sock
       (concat
        (json-encode
         `(:buffer ,(if (bufferp buffer)
                        (buffer-name buffer)
                      buffer)
           :ip ,(emdocs-get-internal-ip-address)))
        "\n"))
    (let* ((json-object-type 'plist)

                           :test #'emdocs-is-ip-from-client)
               (emdocs-connect-client buffer ip)))
            (cur-point
             (with-current-buffer buffer
               (when emdocs-mode
                 (save-excursion
                   (setq emdocs-is-network-insert t)
