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

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

[elpa] externals/org-real 4246089 096/160: Rotate locations of box when


From: ELPA Syncer
Subject: [elpa] externals/org-real 4246089 096/160: Rotate locations of box when cycling
Date: Wed, 6 Oct 2021 16:58:23 -0400 (EDT)

branch: externals/org-real
commit 42460896ae2b8aeeda2895ddaff22873a4e60965
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>

    Rotate locations of box when cycling
    
    Now, pressing enter on a box will take you to the last location that
    was cycled using `o`
---
 org-real.el | 71 +++++++++++++++++++++++++++++++------------------------------
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/org-real.el b/org-real.el
index f3f1635..7980f24 100644
--- a/org-real.el
+++ b/org-real.el
@@ -1531,48 +1531,49 @@ characters if possible."
 
 ;;;; Org real mode buttons
 
-(defun org-real--jump-other-window (markers)
-  "Jump to location of link in other window.
-
-MARKERS is a list of locations of each button in the buffer."
-  (let ((i 0))
+(defun org-real--jump-other-window (box)
+  "Jump to location of link for BOX in other window."
+  (with-slots (locations) box
     (lambda ()
       (interactive)
-      (let* ((marker (nth i markers))
+      (let ((first (car locations)))
+        (object-remove-from-list box :locations first)
+        (object-add-to-list box :locations first t))
+      (let* ((marker (car locations))
              (buffer (marker-buffer marker))
              (pos (marker-position marker)))
         (save-selected-window
           (switch-to-buffer-other-window buffer)
-          (goto-char pos))
-        (setq i (mod (+ 1 i) (length markers)))))))
-
-(defun org-real--jump-to (marker)
-  "Jump to the first occurrence of a link in the same window.
+          (goto-char pos))))))
 
-MARKER is the position of the first occurrence of the link."
-  (let ((buffer (marker-buffer marker)))
+(defun org-real--jump-to (box)
+  "Jump to the first occurrence of a link for BOX in the same window."
+  (with-slots (locations) box
     (lambda ()
       (interactive)
-      (if-let ((window (get-buffer-window buffer)))
-          (select-window window)
-        (switch-to-buffer buffer))
-      (goto-char (marker-position marker)))))
-
-(defun org-real--jump-all (markers)
-  "View all occurrences of a link in the same window.
+      (let* ((marker (car locations))
+             (buffer (marker-buffer marker))
+             (pos (marker-position marker)))
+        (if-let ((window (get-buffer-window buffer)))
+            (select-window window)
+          (switch-to-buffer buffer))
+        (goto-char pos)))))
 
-MARKERS is the list of positions of the link."
-  (lambda ()
-    (interactive)
-    (let ((size (/ (window-height) (length markers))))
-      (or (<= window-min-height size)
-          (error "To many buffers to visit simultaneously"))
-      (switch-to-buffer (marker-buffer (car markers)))
-      (goto-char (marker-position (car markers)))
-      (dolist (marker (cdr markers))
-        (select-window (split-window nil size))
+(defun org-real--jump-all (box)
+  "View all occurrences of links from BOX in the same window."
+  (with-slots (locations) box
+    (lambda ()
+      (interactive)
+      (let* ((size (/ (window-height) (length locations)))
+             (marker (car locations)))
+        (or (<= window-min-height size)
+            (error "To many buffers to visit simultaneously"))
         (switch-to-buffer (marker-buffer marker))
-        (goto-char (marker-position marker))))))
+        (goto-char (marker-position marker))
+        (dolist (marker (cdr locations))
+          (select-window (split-window nil size))
+          (switch-to-buffer (marker-buffer marker))
+          (goto-char (marker-position marker)))))))
 
 (cl-defmethod org-real--create-button-keymap ((box org-real-box))
   "Create a keymap for a button in Org Real mode.
@@ -1583,10 +1584,10 @@ BOX is the box the button is being made for."
      (mapcar
       (lambda (key) (cons (kbd (car key)) (cdr key)))
       `(("TAB"       . ,(org-real--cycle-children box))
-        ("o"         . ,(org-real--jump-other-window locations))
-        ("<mouse-1>" . ,(org-real--jump-to (car locations)))
-        ("RET"       . ,(org-real--jump-to (car locations)))
-        ("M-RET"     . ,(org-real--jump-all locations)))))))
+        ("o"         . ,(org-real--jump-other-window box))
+        ("<mouse-1>" . ,(org-real--jump-to box))
+        ("RET"       . ,(org-real--jump-to box))
+        ("M-RET"     . ,(org-real--jump-all box)))))))
 
 ;;;; Utility expressions
 



reply via email to

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