[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt d9d7100 53/80: remote process support
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt d9d7100 53/80: remote process support |
Date: |
Sat, 28 Aug 2021 10:57:41 -0400 (EDT) |
branch: externals/crdt
commit d9d7100abc1d01e82fa31f28e8512a22c684c639
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
remote process support
---
HACKING.org | 5 +++++
crdt.el | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/HACKING.org b/HACKING.org
index 44a8245..b4c4621 100644
--- a/HACKING.org
+++ b/HACKING.org
@@ -115,6 +115,11 @@ and second last two bytes represent site ID.
- overlay-remove ::
body takes the form =(buffer-name site-id logical-clock)=
+
+ - process ::
+ body takes the form =(buffer-name string)=
+ Sent from client to server, request sending =string=
+ to the process buffer associated to =buffer-name=.
* Emacs as a collaborative operating system
diff --git a/crdt.el b/crdt.el
index 21278ef..fdd9c15 100644
--- a/crdt.el
+++ b/crdt.el
@@ -326,6 +326,8 @@ to avoid recusive calling of CRDT synchronization
functions.")
(crdt--defvar-permanent-local crdt--buffer-sync-callback)
+(crdt--defvar-permanent-local crdt--buffer-pseudo-process)
+
;;; Global variables
(defvar crdt--session-list nil)
@@ -1868,5 +1870,59 @@ Join with DISPLAY-NAME."
(cl-loop for command in '(org-cycle org-shifttab)
do (advice-add command :around #'crdt--org-overlay-advice))
+;;; pseudo process
+(cl-defstruct (crdt--pseudo-process (:constructor crdt--make-pseudo-process))
+ buffer)
+
+(defun crdt--pseudo-process-send-string (pseudo-process string)
+ (with-current-buffer (crdt--pseudo-process-buffer pseudo-process)
+ (crdt--broadcast-maybe (crdt--format-message
+ `(process ,crdt--buffer-network-name ,string)))))
+
+(defun crdt--process-send-string-advice (orig-func process string)
+ (if (crdt--pseudo-process-p process)
+ (crdt--pseudo-process-send-string process string)
+ (funcall orig-func process string)))
+
+(defun crdt--process-send-region-advice (orig-func process start end)
+ (if (crdt--pseudo-process-p process)
+ (crdt--pseudo-process-send-string process
(buffer-substring-no-properties start end))
+ (funcall orig-func process start end)))
+
+(defun crdt--get-buffer-process-advice (orig-func buffer)
+ (and (setq buffer (get-buffer buffer))
+ (with-current-buffer buffer
+ (if (and crdt--session (not (crdt--server-p)))
+ (or crdt--buffer-pseudo-process
+ (setq crdt--buffer-pseudo-process
+ (crdt--make-pseudo-process :buffer buffer)))
+ (funcall orig-func buffer)))))
+
+(defun crdt--process-status-advice (orig-func process)
+ (if (crdt--pseudo-process-p process)
+ 'run
+ (funcall orig-func process)))
+
+(defun crdt--process-buffer-advice (orig-func process)
+ (if (crdt--pseudo-process-p process)
+ (crdt--pseudo-process-buffer process)
+ (funcall orig-func process)))
+
+(defun crdt--processp-advice (orig-func object)
+ (or (crdt--pseudo-process-p object) (funcall orig-func object)))
+
+(advice-add 'process-send-string :around #'crdt--process-send-string-advice)
+(advice-add 'process-send-region :around #'crdt--process-send-region-advice)
+(advice-add 'processp :around #'crdt--processp-advice)
+(advice-add 'get-buffer-process :around #'crdt--get-buffer-process-advice)
+(advice-add 'process-status :around #'crdt--process-status-advice)
+(advice-add 'process-buffer :around #'crdt--process-buffer-advice)
+
+(cl-defmethod crdt-process-message ((message (head process)) process)
+ (cl-destructuring-bind (buffer-name string) (cdr message)
+ (crdt--with-buffer-name
+ buffer-name
+ (process-send-string (get-buffer-process (current-buffer)) string))))
+
(provide 'crdt)
;;; crdt.el ends here
- [elpa] externals/crdt e1b0fe9 02/80: Fixed silly typo!, (continued)
- [elpa] externals/crdt e1b0fe9 02/80: Fixed silly typo!, ELPA Syncer, 2021/08/28
- [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 <=
- [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, 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