emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 03/03: Small cleanup in chess-ply--move-text.


From: Mario Lang
Subject: [elpa] 03/03: Small cleanup in chess-ply--move-text.
Date: Tue, 03 Jun 2014 21:45:47 +0000

mlang pushed a commit to branch externals/chess
in repository elpa.

commit eaa2b63142d5f73c2ba936c2d82fc0e68984c167
Author: Mario Lang <address@hidden>
Date:   Tue Jun 3 23:44:15 2014 +0200

    Small cleanup in chess-ply--move-text.
    
    Remove dead code (prog1), redo nested if with cond, and use
    chess-index-rank and chess-index-file where appropriate.
---
 chess-algebraic.el |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/chess-algebraic.el b/chess-algebraic.el
index daab1ba..8fb4fa0 100644
--- a/chess-algebraic.el
+++ b/chess-algebraic.el
@@ -168,10 +168,10 @@ This regexp handles both long and short form.")
          (let ((candidates (chess-search-position pos to from-piece nil t)))
            (when (> (length candidates) 1)
              (dolist (candidate candidates)
-               (if (= (/ candidate 8) from-rank)
-                   (setq rank (1+ rank)))
-               (if (= (mod candidate 8) from-file)
-                   (setq file (1+ file))))
+               (when (= (chess-index-rank candidate) from-rank)
+                 (setq rank (1+ rank)))
+               (when (= (chess-index-file candidate) from-file)
+                 (setq file (1+ file))))
              (cond
               ((= file 1)
                (setq differentiator (+ from-file ?a)))
@@ -182,16 +182,12 @@ This regexp handles both long and short form.")
        (concat
         (unless (= (upcase from-piece) ?P)
           (char-to-string (upcase from-piece)))
-        (if long
-            (chess-index-to-coord from)
-          (if differentiator
-              (prog1
-                  (char-to-string differentiator)
-                (chess-ply-changes ply))
-            (if (and (not long) (= (upcase from-piece) ?P)
-                     (/= (chess-index-file from)
-                         (chess-index-file to)))
-                (char-to-string (+ (chess-index-file from) ?a)))))
+        (cond
+         (long (chess-index-to-coord from))
+         (differentiator (char-to-string differentiator))
+         ((and (not long) (= (upcase from-piece) ?P)
+               (/= from-file (chess-index-file to)))
+          (char-to-string (+ from-file ?a))))
         (if (or (/= ?  (chess-pos-piece pos to))
                 (chess-ply-keyword ply :en-passant))
             "x" (if long "-"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]