]> code.delx.au - gnu-emacs-elpa/blobdiff - chess-var.el
Add examples for chess-plain and chess-ics1 to the manual.
[gnu-emacs-elpa] / chess-var.el
index c69e00ca8f9a754ad8ce7921e920aaed205e9d03..58c1c7b0736b0934314429f13d844f8eb1ab6759 100644 (file)
@@ -22,6 +22,7 @@
 
 ;;; Code:
 
+(require 'chess-algebraic)
 (require 'chess-ply)
 (eval-when-compile (require 'cl-lib))
 
@@ -59,7 +60,7 @@ of the variation if INDEX is nil)."
     (car (last (chess-var-plies var)))))
 
 (defun chess-var-add-ply (var ply)
-  "Return the position related to VAR's INDEX position."
+  "Add to VAR the given PLY."
   (cl-assert var)
   (cl-assert (listp ply))
   (let ((plies (chess-var-plies var)))
@@ -79,23 +80,23 @@ progress (nil), if it is drawn, resigned, mate, etc."
   (cl-assert var)
   (cl-assert (listp ply))
   (let ((current-ply (chess-var-ply var))
-       (changes (chess-ply-changes ply))
-       (position (chess-ply-pos ply)))
+       (changes (chess-ply-changes ply)))
     (if (chess-ply-final-p current-ply)
        (chess-error 'add-to-completed))
-    (cl-assert (eq position (chess-ply-pos current-ply)))
+    (cl-assert (eq (chess-ply-pos ply) (chess-ply-pos current-ply)))
     (chess-ply-set-changes current-ply changes)
     (chess-var-add-ply var (chess-ply-create*
                            (chess-ply-next-pos current-ply)))))
 
-(defun chess-var-to-algebraic (var &optional long)
-  "Reveal the plies of VAR by converting them to algebraic
-notation."
+(defun chess-var-to-algebraic (var &optional type)
+  "Reveal the plies of VAR by converting them to algebraic notation.
+Optional argument TYPE defines the type of algebraic notation to use
+(`:san', `:lan' or `:fan'."
   (mapconcat (lambda (ply)
-              (chess-ply-to-algebraic ply long))
+              (chess-ply-to-algebraic ply type))
             (if (chess-ply-final-p (chess-var-ply var))
                 (chess-var-plies var)
-              (reverse (cdr (reverse (chess-var-plies var)))))
+              (butlast (chess-var-plies var)))
             " "))
 
 (provide 'chess-var)