emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/crdt 780478a090 39/44: Fix crdt--cycle-user bug with di


From: ELPA Syncer
Subject: [elpa] externals/crdt 780478a090 39/44: Fix crdt--cycle-user bug with different buffer/window
Date: Sat, 2 Jul 2022 22:57:35 -0400 (EDT)

branch: externals/crdt
commit 780478a090bba3a5ce927db1ca7dcc3bd7a801f8
Author: Qiantan Hong <qhong@alum.mit.edu>
Commit: Qiantan Hong <qhong@alum.mit.edu>

    Fix crdt--cycle-user bug with different buffer/window
---
 crdt.el | 65 +++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/crdt.el b/crdt.el
index cfedcc59f3..baa79b2bbf 100644
--- a/crdt.el
+++ b/crdt.el
@@ -917,25 +917,22 @@ Directly return the user name under point if in the user 
menu."
       (crdt--read-user session)
       (signal 'quit nil)))
 
-(defun crdt-goto-user (session user-id &optional noswitch)
-  "Goto the cursor location of user with USER-ID in SESSION.
-If NOSWITCH is non-nil, don't switch window."
+(defun crdt-goto-user (session user-id)
+  "Goto the cursor location of user with USER-ID in SESSION."
   (interactive (let ((session (crdt--read-session-maybe)))
                  (list session (crdt--read-user-maybe session))))
-  (let ((crdt--session session))
+  (let ((crdt--session session)
+        (switch-window-function
+         (if (eq major-mode 'crdt-user-menu-mode) 
#'switch-to-buffer-other-window #'switch-to-buffer)))
     (if (eq user-id (crdt--session-local-id crdt--session))
-        (unless noswitch
-          (funcall (if (eq major-mode 'crdt-user-menu-mode)
-                       #'switch-to-buffer-other-window
-                     #'switch-to-buffer)
-                   (gethash (crdt--session-focused-buffer-name crdt--session) 
(crdt--session-buffer-table crdt--session))))
+        (funcall switch-window-function
+                 (gethash (crdt--session-focused-buffer-name crdt--session) 
(crdt--session-buffer-table crdt--session)))
       (unless
           (cl-block nil
             (let* ((metadata (or (gethash user-id (crdt--session-contact-table 
crdt--session)) (cl-return)))
                    (buffer-name (or (crdt--contact-metadata-focus metadata) 
(cl-return))))
               (crdt--with-buffer-name-pull (buffer-name)
-               (unless noswitch
-                  (switch-to-buffer-other-window (current-buffer)))
+                (funcall switch-window-function (current-buffer))
                (ignore-errors (goto-char (overlay-start (car (gethash user-id 
crdt--pseudo-cursor-table)))))
                t)))
         (message "Doesn't have position information for this user yet.")))))
@@ -955,27 +952,31 @@ When moving into/out of ourselves, push/pop a global 
marker instead."
   (unless crdt--session
     (error "Not a CRDT shared buffer"))
   (crdt--session-ensure-user-menu-buffer crdt--session)
-  (let ((mark (point-marker)))
-    (with-current-buffer (crdt--session-user-menu-buffer crdt--session)
-      (when (= (point) (point-max))
-        (forward-line -1))
-      (when (eq (tabulated-list-get-id) (crdt--session-local-id crdt--session))
-        (setf (crdt--session-my-location-marker crdt--session) mark)
-        (add-to-history 'global-mark-ring mark global-mark-ring-max t))
-      (if prev
-          (unless (= (forward-line -1) 0)
-            (goto-char (point-max))
-            (forward-line -1))
-        (forward-line)
-        (when (= (point) (point-max))
-          (goto-char (point-min))))
-      (let ((window (get-buffer-window (current-buffer) t)))
-        (when window (set-window-point window (point))))
-      (if (eq (tabulated-list-get-id) (crdt--session-local-id crdt--session))
-          (if (eq (car global-mark-ring) (crdt--session-my-location-marker 
crdt--session))
-              (pop-global-mark)
-            (goto-char (crdt--session-my-location-marker crdt--session)))
-        (crdt-goto-user crdt--session (tabulated-list-get-id) t)))))
+  (let* ((mark (point-marker))
+         (user-id
+          (with-current-buffer (crdt--session-user-menu-buffer crdt--session)
+            (when (= (point) (point-max))
+              (forward-line -1))
+            (when (eq (tabulated-list-get-id) (crdt--session-local-id 
crdt--session))
+              (setf (crdt--session-my-location-marker crdt--session) mark)
+              (add-to-history 'global-mark-ring mark global-mark-ring-max t))
+            (if prev
+                (unless (= (forward-line -1) 0)
+                  (goto-char (point-max))
+                  (forward-line -1))
+              (forward-line)
+              (when (= (point) (point-max))
+                (goto-char (point-min))))
+            (let ((window (get-buffer-window (current-buffer) t)))
+              (when window (set-window-point window (point))))
+            (if (eq (tabulated-list-get-id) (crdt--session-local-id 
crdt--session))
+                (when (crdt--session-my-location-marker crdt--session)
+                  (if (eq (car global-mark-ring) 
(crdt--session-my-location-marker crdt--session))
+                      (pop-global-mark)
+                    (goto-char (crdt--session-my-location-marker 
crdt--session)))
+                  nil)
+              (tabulated-list-get-id)))))
+    (when user-id (crdt-goto-user crdt--session user-id))))
 
 (defun crdt-goto-next-user ()
   "Move point in user menu buffer to next user and goto its cursor position.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]