branch: externals/vundo
commit ca590c571546eb1d38c855216db11d28135892f2
Author: 45mg <45mm.cartridge...@slmail.me>
Commit: Yuan Fu <caso...@gmail.com>

    Add a command for ing to the beginning of next stem
    
    To switch branches, one needs to be on a stem root (branchpoint). Add
    a command to make it easier to move between stem roots (meant to be
    used along with `vundo-stem-root').
    
    * vundo.el (vundo-next-root): New command.
    * README.txt: Mention new command.
    * NEWS.txt: Add news for the new command.
---
 NEWS.txt   |  7 +++++++
 README.txt |  1 +
 vundo.el   | 24 ++++++++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/NEWS.txt b/NEWS.txt
index dc0ddc5ad5..c398f8eb33 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,3 +1,10 @@
+TBD
+
+New features:
+
+- Now there’s a new command ‘w’ in the vundo buffer, typing it brings
+  you forward to the next branching point.
+
 <2023-12-08 Fri>: Version 2.5.0
 
 vundo-diff introduced, providing on-demand diff functionality.  Diff's
diff --git a/README.txt b/README.txt
index 41fd5d1660..36b46fc321 100644
--- a/README.txt
+++ b/README.txt
@@ -12,6 +12,7 @@ should pop up. To move around, type:
   p   to go to the node above
 
   a   to go back to the last branching point
+  w   to go forward to the next branching point
   e   to go forward to the end/tip of the branch
   l   to go to the last saved node
   r   to go to the next saved node
diff --git a/vundo.el b/vundo.el
index e40d4d0e0b..e467516a62 100644
--- a/vundo.el
+++ b/vundo.el
@@ -756,6 +756,7 @@ WINDOW is the window that was/is displaying the vundo 
buffer."
     (define-key map (kbd "p") #'vundo-previous)
     (define-key map (kbd "<up>") #'vundo-previous)
     (define-key map (kbd "a") #'vundo-stem-root)
+    (define-key map (kbd "w") #'vundo-next-root)
     (define-key map (kbd "e") #'vundo-stem-end)
     (define-key map (kbd "l") #'vundo-goto-last-saved)
     (define-key map (kbd "r") #'vundo-goto-next-saved)
@@ -1324,6 +1325,29 @@ If ARG < 0, move forward."
       vundo--orig-buffer (current-buffer)
       'incremental))))
 
+(defun vundo-next-root ()
+  "Move to the beginning of the next stem."
+  (interactive)
+  (vundo--check-for-command
+   (when-let* ((this (vundo--current-node vundo--prev-mod-list))
+               ;; If NEXT is nil, ie. this node doesn’t have a child, do
+               ;; nothing.
+               (next (car (vundo-m-children this))))
+     (vundo--move-to-node
+      this next vundo--orig-buffer vundo--prev-mod-list)
+     (setq this next
+           next (car (vundo-m-children this)))
+     (while (and next (not (vundo--stem-root-p this)))
+       (vundo--move-to-node
+        this next vundo--orig-buffer vundo--prev-mod-list)
+       (setq this next
+             next (car (vundo-m-children this))))
+     (vundo--trim-undo-list
+      vundo--orig-buffer this vundo--prev-mod-list)
+     (vundo--refresh-buffer
+      vundo--orig-buffer (current-buffer)
+      'incremental))))
+
 (defun vundo-stem-end ()
   "Move to the end of the current stem."
   (interactive)

Reply via email to