[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/crdt ea632a3 26/80: some docstring and unused variable
From: |
ELPA Syncer |
Subject: |
[elpa] externals/crdt ea632a3 26/80: some docstring and unused variable |
Date: |
Sat, 28 Aug 2021 10:57:35 -0400 (EDT) |
branch: externals/crdt
commit ea632a32341bb57ff786cb1f9b4404d0a48aeacc
Author: Qiantan Hong <qhong@mit.edu>
Commit: Qiantan Hong <qhong@mit.edu>
some docstring and unused variable
---
crdt.el | 92 ++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 48 insertions(+), 44 deletions(-)
diff --git a/crdt.el b/crdt.el
index 5f6d46e..0e470c1 100644
--- a/crdt.el
+++ b/crdt.el
@@ -78,7 +78,6 @@ and there are some client connected to it currently."
"Move pseudo cursor overlay OV to POS."
;; Hax!
(let* ((eof (eq pos (point-max)))
- (eol (unless eof (eq (char-after pos) ?\n)))
(end (if eof pos (1+ pos)))
(display-string
(when eof
@@ -340,18 +339,6 @@ to avoid recusive calling of CRDT synchronization
functions.")
;;; crdt-mode
-(defun crdt--kill-buffer-hook ()
- (when crdt--buffer-network-name
- (puthash crdt--buffer-network-name nil (crdt--buffer-table))
- (crdt--broadcast-maybe (crdt--format-message
- `(cursor ,crdt--buffer-network-name
- ,(crdt--local-id) nil nil nil nil)))
- (when (eq (crdt--focused-buffer-name) crdt--buffer-network-name)
- (crdt--broadcast-maybe (crdt--format-message
- `(focus ,(crdt--local-id) nil)))
- (setf (crdt--focused-buffer-name) nil))
- (crdt--refresh-users-maybe)))
-
(defun crdt--install-hooks ()
(add-hook 'after-change-functions #'crdt--after-change nil t)
(add-hook 'before-change-functions #'crdt--before-change nil t)
@@ -383,22 +370,11 @@ to avoid recusive calling of CRDT synchronization
functions.")
(crdt--clear-pseudo-cursor-table)
(setq crdt--overlay-table nil)))
+
;;; Shared buffer utils
-(defun crdt--with-buffer-name-make-body (name body fallback)
- `(let (crdt-buffer)
- (setq crdt-buffer (gethash ,name crdt--buffer-table))
- (if (and crdt-buffer (buffer-live-p crdt-buffer))
- (with-current-buffer crdt-buffer
- ,@body)
- (unless (process-contact crdt--network-process :server)
- (setq crdt-buffer (generate-new-buffer (format "crdt - %s" ,name)))
- (puthash ,name crdt-buffer crdt--buffer-table)
- (let ((status-buffer (current-buffer)))
- (with-current-buffer crdt-buffer
- (setq crdt--buffer-network-name ,name)
- (setq crdt--status-buffer status-buffer)
- (crdt-mode)
- ,(funcall fallback name body)))))))
+(defsubst crdt--server-p ()
+ "For a CRDT shared buffer, tell if its session is running as a server."
+ (process-contact (crdt--network-process) :server))
(defmacro crdt--with-buffer-name (name &rest body)
"Find CRDT shared buffer associated with NAME and evaluate BODY in it.
@@ -413,25 +389,41 @@ If such buffer doesn't exist yet, do nothing."
,@body)))))
(defmacro crdt--with-buffer-name-pull (name &rest body)
- (crdt--with-buffer-name-make-body
- name body
- (lambda (name body)
- `(progn
- (crdt--broadcast-maybe (crdt--format-message `(get ,,name)))
- (let ((crdt--inhibit-update t))
- (insert "Synchronizing with server..."))
- (setq crdt--buffer-sync-callback
- (lambda ()
- ,@body))))))
+ "Find CRDT shared buffer associated with NAME and evaluate BODY in it.
+Must be called when CURRENT-BUFFER is a CRDT status buffer.
+If such buffer doesn't exist yet, request it from the server,
+and store the body in CRDT--BUFFER-SYNC-CALLBACK to evaluate it
+after synchronization is completed."
+ `(let (crdt-buffer)
+ (setq crdt-buffer (gethash ,name crdt--buffer-table))
+ (if (and crdt-buffer (buffer-live-p crdt-buffer))
+ (with-current-buffer crdt-buffer
+ ,@body)
+ (unless (process-contact crdt--network-process :server)
+ (setq crdt-buffer (generate-new-buffer (format "crdt - %s" ,name)))
+ (puthash ,name crdt-buffer crdt--buffer-table)
+ (let ((status-buffer (current-buffer)))
+ (with-current-buffer crdt-buffer
+ (setq crdt--buffer-network-name ,name)
+ (setq crdt--status-buffer status-buffer)
+ (crdt-mode)
+ (crdt--broadcast-maybe (crdt--format-message `(get ,,name)))
+ (let ((crdt--inhibit-update t))
+ (insert "Synchronizing with server..."))
+ (setq crdt--buffer-sync-callback
+ (lambda ()
+ ,@body))))))))
;;; Session menu
(defun crdt--session-menu-goto ()
+ "Open the buffer menu for the session under point in CRDT session menu."
(interactive)
(with-current-buffer
(tabulated-list-get-id)
(crdt-list-buffer)))
(defun crdt--session-menu-kill ()
+ "Kill the session under point in CRDT session menu."
(interactive)
(with-current-buffer
(tabulated-list-get-id)
@@ -451,10 +443,9 @@ If such buffer doesn't exist yet, do nothing."
("Buffers" 30 t)
("Users" 15 t)]))
-(defun crdt-list-sessions (&optional crdt-buffer display-buffer)
+(defun crdt-list-sessions (&optional display-buffer)
"Display a list of active CRDT sessions.
-If DISPLAY-BUFFER is provided, display the output there.
-Otherwise use a dedicated buffer for displaying active users on CRDT-BUFFER."
+If DISPLAY-BUFFER is provided, display the output there."
(interactive)
(unless display-buffer
(unless (and crdt--session-menu-buffer (buffer-live-p
crdt--session-menu-buffer))
@@ -496,6 +487,7 @@ Otherwise use a dedicated buffer for displaying active
users on CRDT-BUFFER."
;;; Buffer menu
(defun crdt--buffer-menu-goto ()
+ "Open the buffer under point in CRDT buffer menu."
(interactive)
(let ((name (tabulated-list-get-id)))
(with-current-buffer crdt--status-buffer
@@ -503,6 +495,8 @@ Otherwise use a dedicated buffer for displaying active
users on CRDT-BUFFER."
(switch-to-buffer-other-window (current-buffer))))))
(defun crdt--buffer-menu-kill ()
+ "Stop sharing the buffer under point in CRDT buffer menu.
+Only server can perform this action."
(interactive)
(if (crdt--server-p)
(let ((name (tabulated-list-get-id)))
@@ -580,6 +574,7 @@ Otherwise use a dedicated buffer for displaying active
users on CRDT-BUFFER."
;;; User menu
(defun crdt--user-menu-goto ()
+ "Goto the cursor location of the user under point in CRDT user menu."
(interactive)
(let ((site-id (tabulated-list-get-id)))
(if (eq site-id (crdt--local-id))
@@ -660,6 +655,18 @@ Otherwise use a dedicated buffer for displaying active
users on CRDT-BUFFER."
(crdt-refresh-users (crdt--user-menu-buffer)))
(crdt--refresh-buffers-maybe))
+(defun crdt--kill-buffer-hook ()
+ (when crdt--buffer-network-name
+ (puthash crdt--buffer-network-name nil (crdt--buffer-table))
+ (crdt--broadcast-maybe (crdt--format-message
+ `(cursor ,crdt--buffer-network-name
+ ,(crdt--local-id) nil nil nil nil)))
+ (when (eq (crdt--focused-buffer-name) crdt--buffer-network-name)
+ (crdt--broadcast-maybe (crdt--format-message
+ `(focus ,(crdt--local-id) nil)))
+ (setf (crdt--focused-buffer-name) nil))
+ (crdt--refresh-users-maybe)))
+
;;; CRDT insert/delete
(defsubst crdt--base64-encode-maybe (str)
@@ -1107,9 +1114,6 @@ to server when WITHOUT is T."
(and mark-crdt-id (base64-decode-string
mark-crdt-id)))))
(crdt--broadcast-maybe (crdt--format-message message) (process-get process
'client-id)))
-(defsubst crdt--server-p ()
- (process-contact (crdt--network-process) :server))
-
(cl-defmethod crdt-process-message ((message (head get)) process)
(cl-destructuring-bind (buffer-name) (cdr message)
(let ((buffer (gethash buffer-name crdt--buffer-table)))
- [elpa] externals/crdt 53e5676 33/80: fix bug with org table, (continued)
- [elpa] externals/crdt 53e5676 33/80: fix bug with org table, ELPA Syncer, 2021/08/28
- [elpa] externals/crdt fcc6a47 38/80: fix upper/lowercase convention, ELPA Syncer, 2021/08/28
- [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 <=
- [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, 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