[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt 900abacbdd 16/44: Use the term "user-command-funct
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt 900abacbdd 16/44: Use the term "user-command-functions" instead of proxy |
Date: |
Sat, 2 Jul 2022 22:57:33 -0400 (EDT) |
branch: externals/crdt
commit 900abacbdd3074076b4093f96d43f220290b63f5
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
Use the term "user-command-functions" instead of proxy
---
crdt.el | 60 +++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 17 deletions(-)
diff --git a/crdt.el b/crdt.el
index 11994aed9c..556e035daf 100644
--- a/crdt.el
+++ b/crdt.el
@@ -301,7 +301,7 @@ Must be used inside CRDT--WITH-INSERTION-INFORMATION."
next-client-id
buffer-table ; maps buffer network name to buffer
follow-user-id
- default-proxies)
+ user-command-functions)
(defvar crdt--inhibit-update nil "When set, don't call CRDT--LOCAL-* on change.
This is useful for functions that apply remote change to local buffer,
@@ -323,10 +323,10 @@ Each element is of the form (CURSOR-OVERLAY .
REGION-OVERLAY).")
(crdt--defvar-permanent-local crdt--site-id-table nil
"A hash table that maps USER-ID to SITE-ID. Only used by the publisher of
the buffer.")
+(crdt--defvar-permanent-local crdt--site-id-list nil
+ "A list of all allocated SITE-ID (except 0 which is reserved for publisher),
sorted by value.")
(crdt--defvar-permanent-local crdt--site-id-use-list nil
"A list of all allocated SITE-ID (except 0 which is reserved for publisher),
sorted by recent usage.")
-(crdt--defvar-permanent-local crdt--site-id-free-list nil
- "A list of all free SITE-ID (except 0 which is reserved for publisher).")
(crdt--defvar-permanent-local crdt--site-id nil "My SITE-ID at this buffer.")
(cl-defstruct (crdt--overlay-metadata
@@ -362,6 +362,15 @@ adding/removing actively tracked overlays.")
(defvar-local crdt--enabled-text-properties nil
"A list of text properties that are tracked and synchronized.")
+(defvar-local crdt-user-command-functions nil
+ "A list that describes policies for public buffer-local commands.
+Each element should be one of
+- a symbol, which should name a command.
+ The command is be made accessible to every user.
+- a function, which should return a list of commands when
+ called with a single argument USER-ID.
+ The returned list of commands is made accessible to the user with USER-ID.")
+
;;; Global variables
(defvar crdt--session-list nil)
@@ -1780,16 +1789,24 @@ Handle received STRING from PROCESS."
;;; Capabilities
(defun crdt-request-site-id ()
- (let ((new-site-id
- (if crdt--site-id-free-list
- (pop crdt--site-id-free-list)
- (let* ((cons (last crdt--site-id-use-list 2))
- (victim-id (cadr cons)))
- ;; todo: notify the victim
- (rplacd cons nil)
- victim-id))))
+ (let (new-site-id)
+ (cl-loop
+ for i in crdt--site-id-list
+ for c on crdt--site-id-list
+ for j in (cdr crdt--site-id-list)
+ if (> j (1+ i))
+ do (progn
+ (setq new-site-id (1+ i))
+ (push (1+ i) (cdr c))
+ (cl-return)))
+ (unless new-site-id
+ (let* ((cons (last crdt--site-id-use-list 2))
+ (victim-id (cadr cons)))
+ ;; todo: notify the victim
+ (rplacd cons nil)
+ (setq new-site-id victim-id)))
(push new-site-id crdt--site-id-use-list)
- (pushash crdt--user-id new-site-id crdt--site-id-table)
+ (puthash crdt--user-id new-site-id crdt--site-id-table)
new-site-id))
;;; UI commands
@@ -1938,7 +1955,7 @@ of the current buffer."
(apply #'crdt-new-session
(crdt--read-settings
(format "*Settings for %s*" session-name)
- `(("Port: " (number-to-string port)
,(crdt--settings-make-ensure-type 'numberp))
+ `(("Port: " (number-to-string ,port)
,(crdt--settings-make-ensure-type 'numberp))
("Session Name: " ,session-name
,(crdt--settings-make-ensure-nonempty session-name))
("Password: " "")
("Display Name: " ,crdt-default-name))))))))
@@ -1957,9 +1974,18 @@ of the current buffer."
(message "Not a CRDT shared buffer.")))
(defun crdt-new-session
- (port session-name password display-name default-proxies)
- "Start a new CRDT session on PORT with SESSION-NAME and DEFAULT-PROXIES.
-Setup up the server with PASSWORD and assign this Emacs DISPLAY-NAME."
+ (port session-name password display-name user-command-functions)
+ "Start a new CRDT session on PORT with SESSION-NAME.
+Setup up the server with PASSWORD and assign this Emacs DISPLAY-NAME.
+USER-COMMAND-FUNCTIONS is a list that describes policies
+for public session-scoped commands.
+Each element should be one of
+- a symbol, which should name a command.
+ The command is be made accessible to every user, in every buffer.
+- a function, which should return a list of commands when
+ called with two arguments USER-ID and BUFFER.
+ The returned list of commands is made accessible
+ to the user with USER-ID in BUFFER."
(let* ((network-process (make-network-process
:name "CRDT Server"
:server t
@@ -1976,7 +2002,7 @@ Setup up the server with PASSWORD and assign this Emacs
DISPLAY-NAME."
:buffer-table (make-hash-table :test 'equal)
:name session-name
:network-process network-process
- :default-proxies default-proxies))
+ :user-command-functions user-command-functions))
(tuntox-p (or (eq crdt-use-tuntox t)
(and (eq crdt-use-tuntox 'confirm)
(yes-or-no-p "Start a tuntox proxy for this
session? ")))))
- [elpa] externals/crdt updated (81b55a27b8 -> 282c48c47c), ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 97427622b1 06/44: fix bug in crdt--stop-session interactive spec, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 1347c678c3 04/44: Use some warning instead of message, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt b421e4e679 10/44: Merge branch 'fix' into development, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 94b0c488b5 09/44: bump version number, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 3dcc9958f6 11/44: cleanup, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 10f423bbef 15/44: Merge branch 'fix' into development, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 900abacbdd 16/44: Use the term "user-command-functions" instead of proxy,
ELPA Syncer <=
- [elpa] externals/crdt 38fdfc5557 07/44: semver, and various fixes, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 270a4099bb 14/44: return -> cl-return, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt d46be72920 05/44: remove base64 mangling and fix a stupid bug, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 3a78c8a615 24/44: Improve settings form when CRDT-USE-STUNNEL is nil, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 569486e6c6 25/44: Lots of changes, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 6726c7f2d0 30/44: Add special cases for completions when there are 0 or 1 candidates, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 0a351b4ce2 35/44: Add crdt-default-tls. Don't use tls by default, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt 39c308368e 36/44: Also add (kbd "d") binding for *-kill-*, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt dfc98d3525 38/44: add crdt-goto-{next, prev}-user, ELPA Syncer, 2022/07/02
- [elpa] externals/crdt dc9ec07fbd 43/44: Revise README, ELPA Syncer, 2022/07/02