From 3222b53d942daa404852e5148ba9d3ebb8fe96d0 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 27 Aug 2018 17:00:35 -0400 Subject: Pre-moves To activate, look for Chess Display Allow Pre Moves in: M-x customize-group chess-display Tested via: make test make test24 (requires evim) --- chess-game.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'chess-game.el') diff --git a/chess-game.el b/chess-game.el index ed38288..8b72035 100644 --- a/chess-game.el +++ b/chess-game.el @@ -75,13 +75,19 @@ matches." (if (and (eq (caar h) function) (or (null data) (eq data (cdar h)))) - (if last-hook - (setcdr last-hook (cdr h)) - (setq hooks (cdr h))) + (if last-hook + (setcdr last-hook (cdr h)) + (setq hooks (cdr h))) (setq last-hook h)) (setq h (cdr h))) (chess-game-set-hooks game hooks))) +(defun chess-game-get-hook-data (game function) + "Get list of corresponding data (nil if none) from all event hooks that match FUNCTION." + (cl-assert game) + (cl-assert function) + (cl-remove-if 'null (mapcar (lambda (h) (if (eq (car h) function) (cdr h))) (chess-game-hooks game)))) + (defsubst chess-game-run-hooks (game &rest args) "Run the event hooks of GAME and pass ARGS." (cl-assert game) @@ -337,7 +343,8 @@ progress (nil), if it is drawn, resigned, mate, etc." (if (chess-ply-keyword ply :resign) (chess-game-run-hooks game 'resign) - (chess-game-run-hooks game 'move current-ply)))) + (chess-game-run-hooks game 'move current-ply) + (chess-game-run-hooks game 'pre-move)))) (defsubst chess-game-end (game keyword) "End GAME, by resignation, draw, etc." -- cgit v1.2.3