[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 93af8b0 68/80: PoC visualize author
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 93af8b0 68/80: PoC visualize author |
Date: |
Sat, 28 Aug 2021 10:57:44 -0400 (EDT) |
branch: externals/crdt
commit 93af8b09f0e9a3423682b50ce254326f386d65ec
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
PoC visualize author
---
crdt.el | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/crdt.el b/crdt.el
index 99349b3..b3b0863 100644
--- a/crdt.el
+++ b/crdt.el
@@ -394,6 +394,29 @@ Also set CRDT--PSEUDO-CURSOR-TABLE to NIL."
(crdt--clear-pseudo-cursor-table)
(setq crdt--overlay-table nil)))
+;;; Author visualization
+
+(defsubst crdt--visualize-author-1 (beg end site)
+ (put-text-property beg end
+ 'font-lock-face `(:underline ,(crdt--get-cursor-color
site))))
+(defun crdt--visualize-author ()
+ (save-restriction
+ (widen)
+ (let ((pos (point-max)))
+ (while (> pos (point-min))
+ (let* ((prev-pos (previous-single-property-change pos 'crdt-id nil
(point-min)))
+ (crdt-id (car-safe (crdt--get-crdt-id-pair prev-pos))))
+ (when crdt-id (crdt--visualize-author-1 prev-pos pos (crdt--id-site
crdt-id)))
+ (setq pos prev-pos))))))
+
+(define-minor-mode crdt-visualize-author-mode
+ "" nil " CRDT-VAuthor" nil
+ (if crdt-visualize-author-mode
+ (crdt--visualize-author)
+ (save-restriction
+ (widen)
+ (remove-list-of-text-properties (point-min) (point-max)
'(font-lock-face)))))
+
;;; Shared buffer utils
(defsubst crdt--server-p (&optional session)
@@ -722,6 +745,8 @@ It informs other peers that the buffer is killed."
(defun crdt--local-insert (beg end)
"To be called after a local insert happened in current buffer from BEG to
END.
Returns a list of (insert type) messages to be sent."
+ (when crdt-visualize-author-mode
+ (crdt--visualize-author-1 beg end (crdt--session-local-id crdt--session)))
(let (resulting-commands)
(crdt--with-insertion-information
(beg end)
@@ -815,6 +840,8 @@ Start the search around POSITION-HINT."
(goto-char beg)
(insert content)
(setq end (point))
+ (when crdt-visualize-author-mode
+ (crdt--visualize-author-1 beg end (crdt--id-site id)))
;; work around for input method overlays
(cl-loop for ov in (overlays-at beg)
do (unless (overlay-get ov 'crdt-meta)
- [elpa] externals/crdt 06a2f1a 46/80: added some docstrings, (continued)
- [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, 2021/08/28
- [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 <=
- [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
- [elpa] externals/crdt 96fbbf3 73/80: Change my email to the permanent one., ELPA Syncer, 2021/08/28
- [elpa] externals/crdt 6363427 79/80: Add indentation and debugging information to macros, ELPA Syncer, 2021/08/28