summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-09-01 20:08:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-09-01 21:35:02 -0400
commit8d899ce1af47b6ef0223ffd51ce77d5b56c39401 (patch)
treed63c7ea52172b6655b43d2db4d9c3a62bd3aa82c
parent115d7294699dbfaf0ac75e56262f549e4366eb15 (diff)
Simplified error message when an algebraic move fails to work.
-rw-r--r--chess-algebraic.el19
1 files changed, 10 insertions, 9 deletions
diff --git a/chess-algebraic.el b/chess-algebraic.el
index e58063a..1f76e1a 100644
--- a/chess-algebraic.el
+++ b/chess-algebraic.el
@@ -36,10 +36,11 @@
(defconst chess-algebraic-pieces-regexp "[RNBKQ]")
+;; jww (2008-09-01): use rx here, like in chess-ics
(defconst chess-algebraic-regexp
(format (concat "\\("
"O-O\\(-O\\)?\\|"
- "\\(%s?\\)/?"
+ "\\(%s?\\)/?" ; what is the / doing here?
"\\([a-h]?[1-8]?\\)"
"\\([x-]?\\)"
"\\([a-h][1-8]\\)"
@@ -58,7 +59,8 @@ This regexp handles both long and short form.")
'((clarify-piece . "Clarify piece to move by rank or file")
(could-not-clarify . "Could not determine which piece to use")
(could-not-diff . "Could not differentiate piece")
- (no-candidates . "There are no candidate moves for '%s'")))
+ (no-candidates . "There are no candidate moves for '%s'")
+ (at-move-string . "At algebraic move '%s': %s")))
(defun chess-algebraic-to-ply (position move &optional trust)
"Convert the algebraic notation MOVE for POSITION to a ply."
@@ -118,19 +120,18 @@ This regexp handles both long and short form.")
(nconc changes (list :promote (aref promotion 0))))))
(when changes
- (when trust
- (if mate
- (nconc changes (list (if (equal mate "#")
- :checkmate
- :check)))))
+ (if (and trust mate)
+ (nconc changes (list (if (equal mate "#")
+ :checkmate
+ :check))))
(unless long-style
(nconc changes (list :san move)))
(condition-case err
(apply 'chess-ply-create position trust changes)
(error
- (error "In algebraic move '%s': %s"
- move (error-message-string err)))))))))
+ (chess-error 'at-move-string
+ move (error-message-string err)))))))))
(defun chess-ply--move-text (ply long)
(or