[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 9a7ce57 56/80: fix fill-paragraph bug
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 9a7ce57 56/80: fix fill-paragraph bug |
Date: |
Sat, 28 Aug 2021 10:57:41 -0400 (EDT) |
branch: externals/crdt
commit 9a7ce57d3449ee241f698baf8d1787435f233cc1
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
fix fill-paragraph bug
handle unusual before/after function correctly
---
crdt.el | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/crdt.el b/crdt.el
index 787aa89..eab105a 100644
--- a/crdt.el
+++ b/crdt.el
@@ -295,7 +295,12 @@ Must be used inside CRDT--WITH-INSERTION-INFORMATION."
This is useful for functions that apply remote change to local buffer,
to avoid recusive calling of CRDT synchronization functions.")
-(crdt--defvar-permanent-local crdt--changed-string nil)
+(crdt--defvar-permanent-local crdt--changed-string nil
+ "Save changed substring in CRDT--BEFORE-CHANGE.")
+
+(crdt--defvar-permanent-local crdt--changed-start nil
+ "Save start character address of changes in
CRDT--BEFORE-CHANGE,
+to recover the portion being overwritten in CRDT--AFTER-CHANGE.")
(crdt--defvar-permanent-local crdt--last-point nil)
@@ -793,10 +798,11 @@ Start the search around POSITION-HINT."
;; (crdt--verify-buffer)
)
-(defun crdt--local-delete (beg end)
+(defun crdt--local-delete (beg end length)
"Handle local deletion event and return a message to be sent to other peers.
-The deletion happens between BEG and END."
- (let ((outer-end end))
+The deletion happens between BEG and END, and have LENGTH."
+ (let ((outer-end end)
+ (crdt--changed-string (crdt--changed-string beg length)))
(crdt--with-insertion-information
(beg 0 nil crdt--changed-string nil (length crdt--changed-string))
(when (crdt--split-maybe)
@@ -807,10 +813,10 @@ The deletion happens between BEG and END."
(crdt--id-replace-offset ending-id (+ 1 left-offset
(length crdt--changed-string))))))))
(crdt--with-insertion-information
((length crdt--changed-string) outer-end crdt--changed-string nil 0 nil)
- (crdt--split-maybe)))
- ;; (crdt--verify-buffer)
- `(delete ,crdt--buffer-network-name
- ,beg ,@ (crdt--dump-ids 0 (length crdt--changed-string)
crdt--changed-string t)))
+ (crdt--split-maybe))
+ ;; (crdt--verify-buffer)
+ `(delete ,crdt--buffer-network-name
+ ,beg ,@ (crdt--dump-ids 0 (length crdt--changed-string)
crdt--changed-string t))))
(defun crdt--remote-delete (position-hint id-items)
"Handle remote deletion message of ID-ITEMS.
@@ -843,7 +849,13 @@ Start the search for those ID-ITEMs around POSITION-HINT."
"Before change hook used by CRDT-MODE.
It saves the content to be changed (between BEG and END) into
CRDT--CHANGED-STRING."
(unless crdt--inhibit-update
- (setq crdt--changed-string (buffer-substring beg end))))
+ (setq crdt--changed-string (buffer-substring beg end))
+ (setq crdt--changed-start beg)))
+
+(defsubst crdt--changed-string (beg length)
+ "Retrieve part of CRDT--CHANGED-STRING starting at BEG with LENGTH before
change."
+ (let ((from (- beg crdt--changed-start)))
+ (substring crdt--changed-string from (+ from length))))
(defsubst crdt--crdt-id-assimilate (template beg &optional object)
"Make the CRDT-ID property after BEG in OBJECT the same as TEMPLATE.
@@ -860,11 +872,9 @@ TEMPLATE should be a string. If OBJECT is NIL, use
current buffer."
(defun crdt--after-change (beg end length)
"After change hook used by CRDT-MODE.
-It examine CRDT--CHANGED-STRING (should be saved by
-CRDT--BEFORE-STRING and whose length shall equal to LENGTH)
-and current content between BEG and END,
-update the CRDT-ID for any newly inserted text,
-and send message to other peers if needed."
+It examine (CRDT--CHANGED-STRING) (should be saved by CRDT--BEFORE-STRING)
+and current content between BEG and END with LENGTH,
+update the CRDT-ID for any newly inserted text, and send message to other
peers if needed."
(when (markerp beg)
(setq beg (marker-position beg)))
(when (markerp end)
@@ -881,14 +891,14 @@ and send message to other peers if needed."
(save-excursion
(goto-char beg)
(if (and (= length (- end beg))
- (string-equal crdt--changed-string
+ (string-equal (crdt--changed-string beg length)
(buffer-substring-no-properties beg end)))
- (crdt--crdt-id-assimilate crdt--changed-string beg)
+ (crdt--crdt-id-assimilate (crdt--changed-string beg length) beg)
(widen)
(with-silent-modifications
(unless (= length 0)
(crdt--broadcast-maybe
- (crdt--format-message (crdt--local-delete beg end))))
+ (crdt--format-message (crdt--local-delete beg end length))))
(unless (= beg end)
(dolist (message (crdt--local-insert beg end))
(crdt--broadcast-maybe
@@ -1074,7 +1084,7 @@ The overlay is FRONT-ADVANCE and REAR-ADVANCE, and lies
between BEG and END."
(base64-encode-string (crdt--get-id end))
(crdt--base64-encode-maybe (crdt--get-id (1- end))))))
-(defun crdt--generate-challenge ()
+(defsubst crdt--generate-challenge ()
"Generate a challenge string for authentication."
(apply #'unibyte-string (cl-loop for i below 32 collect (random 256))))
- [elpa] externals/crdt 88cd9a1 03/80: refactorz, (continued)
- [elpa] externals/crdt 88cd9a1 03/80: refactorz, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 432b5f8 04/80: two bug fixes for CRDT algorithm, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 82a7565 10/80: fix authentication bug, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt b95111c 15/80: add makefile, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 60bb2ac 07/80: lots of functionalities, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt a157310 12/80: better formatting, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 5ec25f7 20/80: input method seems to work now, ELPA Syncer, 2021/08/28
- [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 <=
- [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, 2021/08/28
- [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