]> code.delx.au - gnu-emacs-elpa/blobdiff - chess-algebraic.el
Don't require `cl'. Miscellaneous cleanups from compiler warnings.
[gnu-emacs-elpa] / chess-algebraic.el
index e9145e7b9924136075017be02320059f025e8798..c0d4038420e8eabb552fb2333c542a2671296efb 100644 (file)
@@ -1,7 +1,26 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Convert a ply to/from standard chess algebraic notation
-;;
+;;; chess-algebraic.el --- Convert a ply to/from standard chess algebraic notation
+
+;; Copyright (C) 2002, 2004, 2008, 2014  Free Software Foundation, Inc.
+
+;; Author: John Wiegley <johnw@gnu.org>
+;; Maintainer: Mario Lang <mlang@delysid.org>
+;; Keywords: games
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
 ;; A thing to deal with in chess is algebraic move notation, such as
 ;; Nxf3+.  (I leave description of this notation to better manuals
 ;; than this).  This notation is a shorthand way of representing where
 ;; buffer:
 ;;
 ;;    chess-algebraic-regexp
-;;
+
+;;; Code:
+
+(eval-when-compile (require 'cl-lib))
 
 (require 'chess-message)
+(require 'chess-pos)
 
 (defconst chess-algebraic-pieces-regexp "[RNBKQ]")
 
@@ -67,8 +90,8 @@ This regexp handles both long and short form.")
 
 (defun chess-algebraic-to-ply (position move &optional trust)
   "Convert the algebraic notation MOVE for POSITION to a ply."
-  (assert (vectorp position))
-  (assert (stringp move))
+  (cl-assert (vectorp position))
+  (cl-assert (stringp move))
   (let ((case-fold-search nil))
     (when (string-match chess-algebraic-regexp-entire move)
       (let ((color (chess-pos-side-to-move position))
@@ -144,7 +167,6 @@ This regexp handles both long and short form.")
          (from (chess-ply-source ply))
          (to (chess-ply-target ply))
          (from-piece (chess-pos-piece pos from))
-         (color (chess-pos-side-to-move pos))
          (rank 0) (file 0)
          (from-rank (chess-index-rank from))
          (from-file (chess-index-file from))
@@ -190,7 +212,7 @@ This regexp handles both long and short form.")
 (defun chess-ply-to-algebraic (ply &optional long)
   "Convert the given PLY to algebraic notation.
 If LONG is non-nil, render the move into long notation."
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (or (and (not long) (chess-ply-keyword ply :san))
       (and (null (chess-ply-source ply)) "")
       (let ((move (chess-ply--move-text ply long)))