[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 1a08765 51/80: slightly cleanup protocol and doc
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 1a08765 51/80: slightly cleanup protocol and doc |
Date: |
Sat, 28 Aug 2021 10:57:40 -0400 (EDT) |
branch: externals/crdt
commit 1a087659999296751ddb6338e1102ff8d2f24ecb
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
slightly cleanup protocol and doc
---
HACKING.org | 12 +++++++++---
crdt.el | 28 ++++++++++++++++++----------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/HACKING.org b/HACKING.org
index 7e3d315..44a8245 100644
--- a/HACKING.org
+++ b/HACKING.org
@@ -70,11 +70,17 @@ and second last two bytes represent site ID.
Might be used for error recovery or other optimization in the future.
One optimization I have in mind is let server try to merge all CRDT item
into a single
one and try to synchronize this state to clients at best effort.
- body takes the form =(buffer-name major-mode . crdt-id-list)=
- - =major-mode= is the major mode used at the server site
- - =content= is the string in the buffer
+ body takes the form =(buffer-name . crdt-id-list)=
- =crdt-id-list= is generated from =CRDT--DUMP-IDS=
+ - ready ::
+ body takes the form =(buffer-name major-mode-symbol)=
+ Indicates the end of a batch of synchronization messages
+ (which usually contains some =cursor= messages, a =sync= message,
+ and some =overlay-*= messages).
+ The client should now try to enable =major-mode-symbol= in the
+ synchronized buffer.
+
- add ::
Indicates that the server has started sharing some buffers.
body takes the form =buffer-name-list=
diff --git a/crdt.el b/crdt.el
index 144777a..50fde7f 100644
--- a/crdt.el
+++ b/crdt.el
@@ -1071,7 +1071,6 @@ The network process for the client connection is PROCESS."
(with-current-buffer buffer
(process-send-string process (crdt--format-message `(sync
,crdt--buffer-network-name
- ,major-mode
,@ (crdt--dump-ids
(point-min) (point-max) nil nil t))))
;; synchronize cursor
(maphash (lambda (site-id ov-pair)
@@ -1110,7 +1109,7 @@ The network process for the client connection is PROCESS."
,(car k) ,(cdr
k) ,prop ,value))))))
crdt--overlay-table)
- (process-send-string process (crdt--format-message `(ready
,crdt--buffer-network-name)))))
+ (process-send-string process (crdt--format-message `(ready
,crdt--buffer-network-name ,major-mode)))))
(defun crdt--greet-client (process)
"Send initial information when a client connects.
@@ -1193,24 +1192,33 @@ The network process for the client connection is
PROCESS."
(cl-defmethod crdt-process-message ((message (head sync)) _process)
(unless (crdt--server-p) ; server shouldn't receive this
- (cl-destructuring-bind (buffer-name mode . ids) (cdr message)
+ (cl-destructuring-bind (buffer-name . ids) (cdr message)
(crdt--with-buffer-name
buffer-name
(let ((crdt--inhibit-update t))
+ (unless crdt--buffer-sync-callback
+ ;; try to get to the same position after sync,
+ ;; if crdt--buffer-sync-callback is not set yet
+ (let ((pos (point)))
+ (setq crdt--buffer-sync-callback
+ (lambda ()
+ (goto-char
+ (max (min pos (point-max))
+ (point-max)))))))
(erase-buffer)
- (crdt--load-ids ids)
- (if (fboundp mode)
- (unless (eq major-mode mode)
- (funcall mode) ; trust your server...
- (crdt-mode))
- (message "Server uses %s, but not available locally." mode)))))
+ (crdt--load-ids ids))))
(crdt--refresh-buffers-maybe)))
(cl-defmethod crdt-process-message ((message (head ready)) _process)
(unless (crdt--server-p) ; server shouldn't receive this
- (cl-destructuring-bind (buffer-name) (cdr message)
+ (cl-destructuring-bind (buffer-name mode) (cdr message)
(crdt--with-buffer-name
buffer-name
+ (if (fboundp mode)
+ (unless (eq major-mode mode)
+ (funcall mode) ; trust your server...
+ (crdt-mode))
+ (message "Server uses %s, but not available locally." mode))
(when crdt--buffer-sync-callback
(funcall crdt--buffer-sync-callback)
(setq crdt--buffer-sync-callback nil))))))
- [elpa] externals/crdt 0608e11 48/80: add tuntox support, fix yank not clearing pseudo-region, (continued)
- [elpa] externals/crdt 0608e11 48/80: add tuntox support, fix yank not clearing pseudo-region, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 5a9ab2d 54/80: support for comint (tested scheme-mode), ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 9d39b42 55/80: quick hack for xscheme.el, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt cb7b701 58/80: add client side recovery, better error message, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 973e761 21/80: Work on Jean's todo list, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 810af7e 32/80: fix bug when beg/end are markers in crdt--*-change, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt fbcb870 31/80: more consistent name, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 58ca0a6 34/80: documents, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 06a2f1a 46/80: added some docstrings, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 2dfff42 50/80: add license, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 1a08765 51/80: slightly cleanup protocol and doc,
ELPA Syncer <=
- [elpa] externals/crdt efdafb9 52/80: fix bug on emacs 25, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 8457254 47/80: fix cursor movement when remote insert/delete, add URL parsing, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 817c265 49/80: fix document, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt bdada96 57/80: Disconnect user command for the server, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 7c9d7ee 64/80: avoid spitting error when POSITION-HINT out of range, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt dc72997 66/80: add mouse alias for RETs in menus, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 2889cae 67/80: change order of READY and OVERLAY-* during initial sync. not sure if this creates more problem, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 93af8b0 68/80: PoC visualize author, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 7875e6a 70/80: remove family for ipv6, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt b5a8a28 71/80: Don't enable buffer process related advices by default., ELPA Syncer, 2021/08/28