[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 515959c 23/80: partially fixed deleted buffer bug
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 515959c 23/80: partially fixed deleted buffer bug |
Date: |
Sat, 28 Aug 2021 10:57:34 -0400 (EDT) |
branch: externals/crdt
commit 515959c70debd46a4f021b3beb3bedace41c50c1
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
partially fixed deleted buffer bug
---
HACKING.org | 4 ++++
crdt.el | 57 +++++++++++++++++++++++++++++++--------------------------
2 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/HACKING.org b/HACKING.org
index d6bc99b..374f5ad 100644
--- a/HACKING.org
+++ b/HACKING.org
@@ -89,6 +89,10 @@ be invoked with no argument in any CRDT shared buffer to
access or modify that s
Indicates that the server has stopped sharing a buffer.
body takes the form =(buffer-name)=
+ - resync ::
+ (TODO) Request the server to resend =sync= message for a buffer.
+ body takes the form =(buffer-name)=
+
- overlay-add ::
body takes the form
#+BEGIN_SRC
diff --git a/crdt.el b/crdt.el
index 8405a73..95bc576 100644
--- a/crdt.el
+++ b/crdt.el
@@ -485,7 +485,7 @@ Otherwise use a dedicated buffer for displaying active
users on CRDT-BUFFER."
(defmacro crdt--with-current-buffer (buffer &rest body)
`(let ((crdt--the-buffer ,buffer))
- (when crdt--the-buffer
+ (when (and crdt--the-buffer (buffer-live-p crdt--the-buffer))
(with-current-buffer crdt--the-buffer
,@body))))
@@ -933,6 +933,30 @@ to server when WITHOUT is T."
(defun crdt--generate-challenge ()
(apply #'unibyte-string (cl-loop for i below 32 collect (random 256))))
+(defsubst crdt--sync-buffer-to-client (buffer 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)
+ (cl-destructuring-bind (cursor-ov . region-ov) ov-pair
+ (let* ((point (overlay-start cursor-ov))
+ (region-beg (overlay-start region-ov))
+ (region-end (overlay-end region-ov))
+ (mark (if (eq point region-beg)
+ (unless (eq point region-end) region-end)
+ region-beg))
+ (point-id-base64 (base64-encode-string (crdt--get-id
point)))
+ (mark-id-base64 (when mark (base64-encode-string
(crdt--get-id mark)))))
+ (process-send-string process
+ (crdt--format-message
+ `(cursor ,crdt--buffer-network-name
,site-id
+ ,point ,point-id-base64
,mark ,mark-id-base64))))))
+ crdt--pseudo-cursor-table)
+ (process-send-string process (crdt--format-message (crdt--local-cursor
nil)))))
+
(defun crdt--greet-client (process)
(with-current-buffer (process-get process 'status-buffer)
(cl-pushnew process crdt--network-clients)
@@ -947,28 +971,7 @@ to server when WITHOUT is T."
,crdt--session-name)))
(cl-incf crdt--next-client-id))
(maphash (lambda (k buffer)
- (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)
- (cl-destructuring-bind (cursor-ov . region-ov)
ov-pair
- (let* ((point (overlay-start cursor-ov))
- (region-beg (overlay-start region-ov))
- (region-end (overlay-end region-ov))
- (mark (if (eq point region-beg)
- (unless (eq point region-end)
region-end)
- region-beg))
- (point-id-base64 (base64-encode-string
(crdt--get-id point)))
- (mark-id-base64 (when mark
(base64-encode-string (crdt--get-id mark)))))
- (process-send-string process
- (crdt--format-message
- `(cursor
,crdt--buffer-network-name ,site-id
- ,point
,point-id-base64 ,mark ,mark-id-base64))))))
- crdt--pseudo-cursor-table)
- (process-send-string process (crdt--format-message
(crdt--local-cursor nil)))))
+ (crdt--sync-buffer-to-client buffer process))
crdt--buffer-table)
;; synchronize contact
(maphash (lambda (k v)
@@ -1234,6 +1237,7 @@ Must be called when CURRENT-BUFFER is a CRDT status
buffer."
,major-mode
,(buffer-substring-no-properties
(point-min) (point-max))
,@ (crdt--dump-ids (point-min) (point-max)
nil)))))
+ (add-hook 'kill-buffer-hook #'crdt-stop-share-buffer nil t)
(crdt--refresh-buffers-maybe)
(crdt--refresh-sessions-maybe))
(error "Only server can add new buffer")))
@@ -1340,9 +1344,10 @@ Disconnect if it's a client session, or stop serving if
it's a server session."
(kill-buffer crdt--user-menu-buffer))
(maphash
(lambda (k v)
- (with-current-buffer v
- (setq crdt--status-buffer nil)
- (crdt-mode 0)))
+ (when (buffer-live-p v)
+ (with-current-buffer v
+ (setq crdt--status-buffer nil)
+ (crdt-mode 0))))
crdt--buffer-table)
(setq crdt--session-list
(delq status-buffer crdt--session-list))
- [elpa] externals/crdt ea632a3 26/80: some docstring and unused variable, (continued)
- [elpa] externals/crdt ea632a3 26/80: some docstring and unused variable, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 68d3067 18/80: bug fix, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt d9d7100 53/80: remote process support, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 9a7ce57 56/80: fix fill-paragraph bug, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt bc98495 60/80: I imagine this fix an imaginary bug with tuntox, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt eb184d8 61/80: clean up *crdt - client*, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 76da6ac 62/80: update buffer/user menu in post-command-hook to account for focus change, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 20ff5b3 65/80: reenable crdt-mode and synchronize after major mode change, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt d20b384 16/80: document and improvements, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 9c37d4d 19/80: remove superfluous crdt--inhibit-update bind, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 515959c 23/80: partially fixed deleted buffer bug,
ELPA Syncer <=
- [elpa] externals/crdt 35d9612 28/80: fix some read functions, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt d10f9c0 30/80: bug fix, debug switch, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 2cee2da 41/80: fix bug in crdt-process-message (head remove), ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 12d9a25 40/80: remove buffer bug, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 903ebf9 36/80: better display for address in user menu, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt e7a3607 45/80: fix cl-block, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt c10b38e 43/80: shorten string when ask for stop session confirmation, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt c495170 09/80: remove debug statements, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt f3e59a4 13/80: usability, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 81f288d 35/80: improve message parser performance, fix buffer list update bug, ELPA Syncer, 2021/08/28