[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board posit
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board position. |
Date: |
Mon, 21 Apr 2014 21:32:08 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 604c87275079013fdd74bbcdaf8411e3c6850b7b
Author: Thien-Thi Nguyen <address@hidden>
Date: Sun Apr 20 17:00:24 2014 +0200
[gnugo] On SGF load, leave cursor at last user board position.
* packages/gnugo/gnugo.el (gnugo-move-history):
Take optional second arg COLOR.
(gnugo-move-history remem): New internal func.
(gnugo-move-history pretty): New internal func.
(gnugo-move-history next): Use ‘remem’, ‘pretty’.
(gnugo-move-history): If RSEL is ‘bpos’, return
the position of the last stone placed by COLOR.
(gnugo-read-sgf-file): Set :last-user-bpos.
(gnugo): After refresh, prefer :last-user-bpos
to :center-position for cursor position.
---
packages/gnugo/NEWS | 6 ++++--
packages/gnugo/gnugo.el | 23 ++++++++++++++++++-----
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index f552702..48b02ac 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -30,7 +30,6 @@ NB: "RCS: X..Y " means that the particular release includes
- new command: ‘L’ (gnugo-frolic-in-the-leaves)
- new command: ‘C-c C-a’ (gnugo-toggle-abdication)
- new major mode: GNUGO Frolic (gnugo-frolic-mode)
- - ‘gnugo-move-history’ returns last two moves w/ RSEL ‘two’
- GNUGO Board mode now derived from Special mode
- performance improvements
- of interest to hackers (see source, BI => backward incompatible)
@@ -38,10 +37,13 @@ NB: "RCS: X..Y " means that the particular release includes
- ‘gnugo/sgf-read-file’ renamed to ‘gnugo/sgf-create’ and enhanced
- ‘:sgf-gametree’ internal representation inverted (BI)
- ‘gnugo-magic-undo’ handles SPEC ‘0’
- - dropped ‘(gnugo-move-history 'count)’ (BI)
- new func: ‘gnugo-current-player’
- new hook: ‘gnugo-start-game-hook’
- ‘gnugo-board-mode-hook’ now unsuitable for prop munging (BI)
+ - changes to ‘gnugo-move-history’
+ - dropped ‘(gnugo-move-history 'count)’ (BI)
+ - returns last two moves w/ RSEL ‘two’
+ - returns position of last placed stone w/ RSEL ‘bpos’ + 2nd arg COLOR
- 2.3.1 | 2014-02-27
- portability fixes
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index e4774c4..256998b 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -708,7 +708,7 @@ when you are sure the command cannot fail."
(+ ?A (- (if (> ?i col) col (1+ col)) ?a))
(- size (- (aref cc 1) ?a))))))))
-(defun gnugo-move-history (&optional rsel)
+(defun gnugo-move-history (&optional rsel color)
"Determine and return the game's move history.
Optional arg RSEL controls side effects and return value.
If nil, display the history in the echo area as \"(N moves)\"
@@ -719,6 +719,7 @@ RSEL may also be a symbol that selects what to return:
car -- the most-recent move
cadr -- the next-to-most-recent move
two -- the last two moves as a list, oldest last
+ bpos -- the last stone on the board placed by COLOR
For all other values of RSEL, do nothing and return nil."
(interactive "P")
(let* ((monkey (gnugo-get :monkey))
@@ -729,9 +730,11 @@ For all other values of RSEL, do nothing and return nil."
((as-pos-maybe (x) (if (string= "resign" x)
x
(funcall as-pos x)))
- (next (byp) (when (setq node (pop mem)
- mprop (gnugo--move-prop node))
- (setq move (as-pos-maybe (cdr mprop)))
+ (remem () (setq node (pop mem)
+ mprop (gnugo--move-prop node)))
+ (pretty () (setq move (as-pos-maybe (cdr mprop))))
+ (next (byp) (when (remem)
+ (pretty)
(push (if byp
(format "%s%s" move (car mprop))
move)
@@ -747,6 +750,13 @@ For all other values of RSEL, do nothing and return nil."
(`car (car (nn)))
(`cadr (nn) (car (nn)))
(`two (nn) (nn) acc)
+ (`bpos (loop with prop = (gnugo--prop<-color color)
+ when (and (remem)
+ (eq prop (car mprop))
+ (pretty)
+ (not (string= "resign" move))
+ (not (gnugo--passp move)))
+ return move))
(_ nil)))))
(define-derived-mode gnugo-frolic-mode special-mode "GNUGO Frolic"
@@ -1913,6 +1923,8 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
(gnugo-move-history 'two))
'two-passes)))
(gnugo-close-game nil game-over))
+ (gnugo-put :last-user-bpos
+ (gnugo-move-history 'bpos (gnugo-get :user-color)))
(gnugo-refresh t)
(set-buffer-modified-p nil)
(gnugo--who-is-who wait play samep)))
@@ -2531,7 +2543,8 @@ See `gnugo-board-mode' for a full list of commands."
handicap)))))))
(gnugo-put :waiting-start (current-time))
(gnugo-refresh t)
- (gnugo-goto-pos (gnugo-get :center-position))
+ (gnugo-goto-pos (or (gnugo-get :last-user-bpos)
+ (gnugo-get :center-position)))
;; first move
(gnugo-put :game-start-time (current-time))
(let ((g (gnugo-get :gnugo-color))
- [elpa] 04/13: [gnugo int] Fix bug: On -l/--infile, inhibit first move if game over., (continued)
- [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, 2014/04/21
- [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 <=