summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-06-27 23:53:09 +0000
committerJohn Wiegley <johnw@newartisans.com>2005-06-27 23:53:09 +0000
commit0ff2c29a361b07c27b6a961193ae3731a765ad51 (patch)
treed7331b808c22781d09f8236bd6fda2537d9b118e
parente2aa9a7a7bd360f46f5343c556c70081979fcddc (diff)
(chess-input-shortcut): If a character is typed that is not a legal
start of a move (which only happens if it's not bound to anything else), just ignore it.
-rw-r--r--chess-input.el56
1 files changed, 30 insertions, 26 deletions
diff --git a/chess-input.el b/chess-input.el
index 54afabe..382c8b9 100644
--- a/chess-input.el
+++ b/chess-input.el
@@ -71,38 +71,42 @@
(setq chess-input-move-string nil))
(unless display-only
(setq chess-input-move-string
- (concat chess-input-move-string (char-to-string last-command-char))))
+ (concat chess-input-move-string
+ (char-to-string last-command-char))))
(unless (and chess-input-moves
(eq position chess-input-moves-pos)
(or (> (length chess-input-move-string) 1)
(eq (car chess-input-moves) last-command-char)))
(setq char (if (eq (downcase last-command-char) ?o) ?k
- last-command-char)
- chess-input-moves-pos position
- chess-input-moves
- (cons char
- (sort
- (mapcar
- (function
- (lambda (ply)
- (cons ply (chess-ply-to-algebraic ply))))
- (if (eq char ?b)
- (append (chess-legal-plies
- position :piece (if color ?P ?p) :file 1)
- (chess-legal-plies
- position :piece (if color ?B ?b)))
- (if (and (>= char ?a)
- (<= char ?h))
- (chess-legal-plies position
- :piece (if color ?P ?p)
- :file (- char ?a))
- (chess-legal-plies position
- :piece (if color
- (upcase char)
- (downcase char))))))
+ last-command-char))
+ (if (or (memq (upcase char) '(?K ?Q ?N ?B ?R ?P))
+ (and (>= char ?a) (<= char ?h)))
+ (setq chess-input-moves-pos position
+ chess-input-moves
+ (cons
+ char
+ (sort
+ (mapcar
(function
- (lambda (left right)
- (string-lessp (cdr left) (cdr right)))))))))
+ (lambda (ply)
+ (cons ply (chess-ply-to-algebraic ply))))
+ (if (eq char ?b)
+ (append (chess-legal-plies
+ position :piece (if color ?P ?p) :file 1)
+ (chess-legal-plies
+ position :piece (if color ?B ?b)))
+ (if (and (>= char ?a)
+ (<= char ?h))
+ (chess-legal-plies position
+ :piece (if color ?P ?p)
+ :file (- char ?a))
+ (chess-legal-plies position
+ :piece (if color
+ (upcase char)
+ (downcase char))))))
+ (function
+ (lambda (left right)
+ (string-lessp (cdr left) (cdr right))))))))))
(let ((moves (delq nil (mapcar 'chess-input-test-move
(cdr chess-input-moves)))))
(cond