[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone |
Date: |
Mon, 21 Apr 2014 21:32:09 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 9916db4253b268ddef7bc093f405e8c28000aea2
Author: Thien-Thi Nguyen <address@hidden>
Date: Mon Apr 21 16:47:41 2014 +0200
[gnugo int] Add abstraction: gnugo--mem-with-played-stone
* packages/gnugo/gnugo.el (gnugo--mem-with-played-stone): New func.
(gnugo--node-with-played-stone): Use it; convert to defsubst.
---
packages/gnugo/gnugo.el | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 10e29e2..52aeb84 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1929,6 +1929,17 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
(set-buffer-modified-p nil)
(gnugo--who-is-who wait play samep)))
+(defun gnugo--mem-with-played-stone (pos)
+ (let ((color (case (following-char)
+ (?X :B)
+ (?O :W))))
+ (when color
+ (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
+ for mem on (aref (gnugo-get :monkey) 0)
+ when (equal fruit (caar mem))
+ return mem
+ finally return nil))))
+
(defun gnugo-magic-undo (spec &optional noalt keep)
"Undo moves on the GNUGO Board, based on SPEC, a string or number.
If SPEC is a string in the form of a board position (e.g., \"T19\"),
@@ -2244,16 +2255,8 @@ which placed the stone at point."
(gnugo-toggle-image-display)
(save-excursion (gnugo-refresh)))
-(defun gnugo--node-with-played-stone (pos)
- (let ((color (case (following-char)
- (?X :B)
- (?O :W))))
- (when color
- (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
- for node in (aref (gnugo-get :monkey) 0)
- if (equal fruit (car node))
- return node
- finally return nil))))
+(defsubst gnugo--node-with-played-stone (pos)
+ (car (gnugo--mem-with-played-stone pos)))
(defun gnugo-describe-position ()
"Display the board position under cursor in the echo area.
- [elpa] branch master updated (1905244 -> a1fe7f0), Thien-Thi Nguyen, 2014/04/21
- [elpa] 01/13: [gnugo int] Add abstraction: gnugo--prop<-color, Thien-Thi Nguyen, 2014/04/21
- [elpa] 03/13: [gnugo int] Fix bug: On -l/--infile, don't set :last-mover., Thien-Thi Nguyen, 2014/04/21
- [elpa] 04/13: [gnugo int] Fix bug: On -l/--infile, inhibit first move if game over., Thien-Thi Nguyen, 2014/04/21
- [elpa] 05/13: [gnugo] Fix bug: DTRT for :last-user-bpos in undo-one-move ME-NEXT., Thien-Thi Nguyen, 2014/04/21
- [elpa] 06/13: [gnugo] Reduce modifier key bouncing for "quick peek" frolics., Thien-Thi Nguyen, 2014/04/21
- [elpa] 09/13: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone,
Thien-Thi Nguyen <=
- [elpa] 07/13: [gnugo int] Add abstraction: gnugo--q/ue, Thien-Thi Nguyen, 2014/04/21
- [elpa] 10/13: [gnugo] Internalize ‘g nugo-magic-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 11/13: [gnugo int] Simplify towards-root loop termination check., Thien-Thi Nguyen, 2014/04/21
- [elpa] 13/13: [gnugo int] Move ‘gnug o-position’ call down-chain., Thien-Thi Nguyen, 2014/04/21
- [elpa] 12/13: [gnugo int] Centralize some "No stone at POS" errors., Thien-Thi Nguyen, 2014/04/21
- [elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board position., Thien-Thi Nguyen, 2014/04/21