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

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

[elpa] externals/gnugo d214e7e 137/357: [gnugo frolic] Add command to se


From: Stefan Monnier
Subject: [elpa] externals/gnugo d214e7e 137/357: [gnugo frolic] Add command to set the main line.
Date: Sun, 29 Nov 2020 14:51:07 -0500 (EST)

branch: externals/gnugo
commit d214e7e7f10b73a737e43c58667b014907641e3f
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo frolic] Add command to set the main line.
    
    * packages/gnugo/gnugo.el (gnugo--swiz): Rename arg SHIFT to BLUNT;
    if BLUNT is a number, validate and take it as ‘b’ directly.
    (gnugo-frolic-set-as-main-line): New command.
    (gnugo-frolic-mode-map): Bind ‘C-m’ to it.
---
 gnugo.el | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 592fbc7..b49841b 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -952,12 +952,17 @@ are dimmed.  Type \\[describe-mode] in that buffer for 
details."
        (gnugo--awake)
      ,@body))
 
-(defun gnugo--swiz (direction &optional shift)
+(defun gnugo--swiz (direction &optional blunt)
   (gnugo--awakened
    (when (> 0 a)
      (setq a bidx))
-   (let* ((b (mod (+ direction a) width))
-          (flit (if shift (lambda (n)
+   (let* ((b (cond ((numberp blunt)
+                    (unless (and (< -1 blunt)
+                                 (< blunt width))
+                      (user-error "No such branch: %s" blunt))
+                    blunt)
+                   (t (mod (+ direction a) width))))
+          (flit (if blunt (lambda (n)
                             (cond ((= n a) b)
                                   ((= n b) a)
                                   (t n)))
@@ -997,6 +1002,11 @@ are dimmed.  Type \\[describe-mode] in that buffer for 
details."
   (interactive)
   (gnugo--swiz 1))
 
+(defun gnugo-frolic-set-as-main-line ()
+  "Make the current branch the main line."
+  (interactive)
+  (gnugo--swiz nil 0))
+
 (defun gnugo-frolic-backward-branch (&optional n)
   "Move backward N (default 1) branches."
   (interactive "p")
@@ -2271,6 +2281,7 @@ starting a new one.  See `gnugo-board-mode' documentation 
for more info."
         ("J"          . gnugo-frolic-rotate-left)
         ("k"          . gnugo-frolic-exchange-right)
         ("K"          . gnugo-frolic-rotate-right)
+        ("\C-m"       . gnugo-frolic-set-as-main-line)
         ("o"          . gnugo-frolic-return-to-origin)))
 
 (unless gnugo-board-mode-map



reply via email to

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