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

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

[elpa] externals/gnugo d62412f 144/357: [gnugo int] Add abstraction: gnu


From: Stefan Monnier
Subject: [elpa] externals/gnugo d62412f 144/357: [gnugo int] Add abstraction: gnugo--move-to-bcol
Date: Sun, 29 Nov 2020 14:51:08 -0500 (EST)

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

    [gnugo int] Add abstraction: gnugo--move-to-bcol
    
    * packages/gnugo/gnugo.el (gnugo--move-to-bcol): New defsubst.
    (gnugo--swiz, gnugo-frolic-prune-branch)
    (gnugo-frolic-backward-branch)
    (gnugo-frolic-forward-branch): Use it.
---
 gnugo.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 951881a..363409b 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -954,6 +954,9 @@ are dimmed.  Type \\[describe-mode] in that buffer for 
details."
        (gnugo--awake)
      ,@body))
 
+(defsubst (gnugo--move-to-bcol bidx)
+  (move-to-column (+ 10 (* 6 bidx))))
+
 (defun gnugo--swiz (direction &optional blunt)
   (gnugo--awakened
    (unless a
@@ -980,7 +983,7 @@ are dimmed.  Type \\[describe-mode] in that buffer for 
details."
      (gnugo-frolic-in-the-leaves)
      (goto-char (point-min))
      (forward-line line)
-     (forward-char (+ 10 (* 6 b))))))
+     (gnugo--move-to-bcol b))))
 
 (defun gnugo-frolic-exchange-left ()
   "Exchange the current branch with the one to its left."
@@ -1036,19 +1039,19 @@ This fails if the monkey is on the current branch
    (when line
      (goto-char (point-min))
      (search-forward line)
-     (move-to-column (+ 10 (* 6 (min a (- width 2))))))))
+     (gnugo--move-to-bcol (min a (- width 2))))))
 
 (defun gnugo-frolic-backward-branch (&optional n)
   "Move backward N (default 1) branches."
   (interactive "p")
   (gnugo--awakened
-   (move-to-column (+ 10 (* 6 (mod (- (or a width) n) width))))))
+   (gnugo--move-to-bcol (mod (- (or a width) n) width))))
 
 (defun gnugo-frolic-forward-branch (&optional n)
   "Move forward N (default 1) branches."
   (interactive "p")
   (gnugo--awakened
-   (move-to-column (+ 10 (* 6 (mod (+ (or a -1) n) width))))))
+   (gnugo--move-to-bcol (mod (+ (or a -1) n) width))))
 
 (defun gnugo-boss-is-near ()
   "Do `bury-buffer' until the current one is not a GNU Board."



reply via email to

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