[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 9f5882c 6/7: Use overlay instead of font-lock-face
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 9f5882c 6/7: Use overlay instead of font-lock-face for crdt-visualize-author-mode |
Date: |
Sun, 29 Aug 2021 22:57:09 -0400 (EDT) |
branch: externals/crdt
commit 9f5882c4ea1d88ba1ed9dd3fc6697e487db23675
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
Use overlay instead of font-lock-face for crdt-visualize-author-mode
---
crdt.el | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/crdt.el b/crdt.el
index 3603472..727e055 100644
--- a/crdt.el
+++ b/crdt.el
@@ -404,17 +404,29 @@ Also set CRDT--PSEUDO-CURSOR-TABLE to 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))))
+ (remove-overlays beg end 'category 'crdt-visualize-author)
+ (cl-flet ((ov-alike-p (ov)
+ (and (eq (overlay-get ov 'category) 'crdt-visualize-author)
+ (eq (overlay-get ov 'crdt-site) site))))
+ (or
+ (let ((ov-front (cl-find-if #'ov-alike-p (overlays-at (1- beg)))))
+ (when ov-front (move-overlay ov-front (overlay-start ov-front) end) t))
+ (let ((ov-rear (cl-find-if #'ov-alike-p (overlays-at end))))
+ (when ov-rear (move-overlay ov-rear beg (overlay-end ov-rear)) t))
+ (let ((new-ov (make-overlay beg end nil t nil)))
+ (overlay-put new-ov 'category 'crdt-visualize-author)
+ (overlay-put new-ov 'crdt-site site)
+ (overlay-put new-ov '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))))))
+ (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
"Minor mode to visualize who wrote what."
@@ -423,7 +435,7 @@ Also set CRDT--PSEUDO-CURSOR-TABLE to NIL."
(crdt--visualize-author)
(save-restriction
(widen)
- (remove-list-of-text-properties (point-min) (point-max)
'(font-lock-face)))))
+ (remove-overlays (point-min) (point-max) 'category
'crdt-visualize-author))))
;;; Shared buffer utils
@@ -858,7 +870,9 @@ Start the search around POSITION-HINT."
(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)
+ do (unless (or (overlay-get ov 'crdt-meta)
+ (memq (overlay-get ov 'category)
+ '(crdt-visualize-author crdt-pseudo-cursor)))
(when (eq (overlay-start ov) beg)
(move-overlay ov end (overlay-end ov)))))
(with-silent-modifications
- [elpa] externals/crdt updated (cfe7748 -> 70ae7ba), ELPA Syncer, 2021/08/29
- [elpa] externals/crdt 8c4a3f4 3/7: More fix on narrowing, ELPA Syncer, 2021/08/29
- [elpa] externals/crdt 9f5882c 6/7: Use overlay instead of font-lock-face for crdt-visualize-author-mode,
ELPA Syncer <=
- [elpa] externals/crdt 3e64983 1/7: fix narrowing behavior, ELPA Syncer, 2021/08/29
- [elpa] externals/crdt 3122172 2/7: Fix narrowing, ELPA Syncer, 2021/08/29
- [elpa] externals/crdt 301b7b1 4/7: Merge branch 'master' into fix, ELPA Syncer, 2021/08/29
- [elpa] externals/crdt a05eb1e 5/7: refactor hook (un)install, ELPA Syncer, 2021/08/29
- [elpa] externals/crdt 70ae7ba 7/7: Merge branch 'fix' into 'master', ELPA Syncer, 2021/08/29