[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 3670b0b 228/357: [gnugo] On SGF load, leave curso
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 3670b0b 228/357: [gnugo] On SGF load, leave cursor at last user board position. |
Date: |
Sun, 29 Nov 2020 14:51:27 -0500 (EST) |
branch: externals/gnugo
commit 3670b0b79f34ef483059ebec4907caa2dab18e7b
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[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.
---
NEWS | 6 ++++--
gnugo.el | 23 ++++++++++++++++++-----
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/NEWS b/NEWS
index f552702..48b02ac 100644
--- a/NEWS
+++ b/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/gnugo.el b/gnugo.el
index e4774c4..256998b 100644
--- a/gnugo.el
+++ b/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] externals/gnugo 5bbec0e 179/357: [gnugo int] Incorporate ‘gnugo-note’ into unique caller., (continued)
- [elpa] externals/gnugo 5bbec0e 179/357: [gnugo int] Incorporate ‘gnugo-note’ into unique caller., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 82b6000 198/357: [gnugo] Mention ‘gnugo-frolic-mode-hook’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 32e8547 199/357: [gnugo int] Add abstraction: gnugo--user-play, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 001228c 205/357: [gnugo] Drop support for ‘(gnugo-move-history 'count)’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 106a279 211/357: [gnugo int] Consolidate paren overlays access., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 17d907d 210/357: [gnugo int] Shave one ‘gnugo-other’ call., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1d6b241 214/357: [gnugo] Use ‘define-derived-mode’ for GNUGO Board mode., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 167ba89 213/357: [gnugo int] Decruft: Streamline game-over handling on SGF load., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b3d3da0 220/357: [gnugo int] Use functional style more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e96b88b 218/357: [gnugo] Decruft: Use ‘gnugo-program’ directly as executable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3670b0b 228/357: [gnugo] On SGF load, leave cursor at last user board position.,
Stefan Monnier <=
- [elpa] externals/gnugo 1020a7f 237/357: [gnugo int] Simplify towards-root loop termination check., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnugo--mem-with-played-stone, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9ae1363 236/357: [gnugo] Internalize ‘gnugo-magic-undo’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a92e184 255/357: fixup! [gnugo int] Decorate w/ plist instead of alist., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 71e1500 245/357: [gnugo] Fix bug: Use ‘gnugo-gate’ for abdication enable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 46f49e3 246/357: [gnugo int] Use ‘gnugo-current-player’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 443903e 249/357: [gnugo int] Drop abstraction: pretty, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a0ecdea 257/357: [gnugo] Conditionalize xform warping on abdication disable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 85e3d91 253/357: [gnugo int] Snoop ‘--handicap N’ for empty new board., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7c7d43c 261/357: [gnugo int] Avoid superfluous ‘gnugo-other’ call., Stefan Monnier, 2020/11/29