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

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

[elpa] 03/06: * chess-ply.el (chess-ply-keyword): Add docstring.


From: Mario Lang
Subject: [elpa] 03/06: * chess-ply.el (chess-ply-keyword): Add docstring.
Date: Mon, 28 Jul 2014 10:09:49 +0000

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

commit 970a24cfcc8bf71a15e5dbc9db6f5538e2fb2920
Author: Mario Lang <address@hidden>
Date:   Mon Jul 28 10:47:03 2014 +0200

    * chess-ply.el (chess-ply-keyword): Add docstring.
    
    * chess-input.el (chess-input): New custom group.
    (chess-input-notation-type): Put into `chess-input' group.
    (chess-input-test-move): Use `chess-ply-keyword' to check for
    castling plies instead of doing a string-match on the algebraic
    notation string.
    
    * chess-images.el (chess-images-determine-size): Don't use
    `x-display-pixel-height' and `x-display-pixel-width' directly.
    
    * chess-display.el (chess-display-draw-square): Make third argument
    PIECE optional.
---
 ChangeLog        |   16 ++++++++++++++++
 chess-display.el |    2 +-
 chess-images.el  |    8 ++------
 chess-input.el   |   24 +++++++++++++++---------
 chess-ply.el     |    6 +++++-
 5 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 935ae2b..c0fdb9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2014-07-28  Mario Lang  <address@hidden>
+
+       * chess-ply.el (chess-ply-keyword): Add docstring.
+
+       * chess-input.el (chess-input): New custom group.
+       (chess-input-notation-type): Put into `chess-input' group.
+       (chess-input-test-move): Use `chess-ply-keyword' to check for
+       castling plies instead of doing a string-match on the algebraic
+       notation string.
+
+       * chess-images.el (chess-images-determine-size): Don't use
+       `x-display-pixel-height' and `x-display-pixel-width' directly.
+
+       * chess-display.el (chess-display-draw-square): Make third argument
+       PIECE optional.
+
 2014-06-29  Mario Lang  <address@hidden>
 
        * chess-algebraic.el (chess-algebraic-to-ply): Remove dead code.
diff --git a/chess-display.el b/chess-display.el
index 857e86d..a5db238 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -351,7 +351,7 @@ also view the same game."
                  (point-min))))))
     (aref chess-display-index-positions index)))
 
-(defun chess-display-draw-square (display index piece &optional pos)
+(defun chess-display-draw-square (display index &optional piece pos)
   (cl-check-type display (or null buffer))
   (cl-check-type index (integer 0 63))
   (cl-check-type piece (member nil ?  ?P ?N ?B ?R ?Q ?K ?p ?n ?b ?r ?q ?k))
diff --git a/chess-images.el b/chess-images.el
index 9b45593..f2e0f03 100644
--- a/chess-images.el
+++ b/chess-images.el
@@ -212,16 +212,12 @@ called."
     (setq cursor-type nil
          chess-images-cache nil
          chess-images-size (chess-images-best-size
-                            (- (if display
-                                   (x-display-pixel-height display)
-                                 (display-pixel-height))
+                            (- (display-pixel-height display)
                                ;; On Macs and Windows, account for
                                ;; the Start/Status bar
                                (if (memq window-system '(mac windows w32))
                                    80 20))
-                            (- (if display
-                                   (x-display-pixel-width display)
-                                 (display-pixel-width)) 20)))))
+                            (- (display-pixel-width display) 20)))))
 
 (defun chess-images-initialize ()
   (let ((map (current-local-map)))
diff --git a/chess-input.el b/chess-input.el
index e34ee50..dc7c8d1 100644
--- a/chess-input.el
+++ b/chess-input.el
@@ -48,8 +48,13 @@
 (make-variable-buffer-local 'chess-input-position-function)
 (make-variable-buffer-local 'chess-input-move-function)
 
+(defgroup chess-input nil
+  "Move input related otpions."
+  :group 'chess)
+
 (defcustom chess-input-notation-type :san
   "Define the notation type to use for move input."
+  :group 'chess-input
   :type '(choice (const :tag "Standard (short) algebraic notation" :san)
                 (const :tag "Numeric notation" :numeric)))
 
@@ -59,19 +64,20 @@
         (i 0) (x 0) (l (length move))
         (xl (length chess-input-move-string)))
     (unless (or (and (equal (downcase chess-input-move-string) "ok")
-                    (string-match "\\`O-O[+#]?\\'" move))
+                    (chess-ply-keyword ply :castle))
                (and (equal (downcase chess-input-move-string) "oq")
-                    (string-match "\\`O-O-O[+#]?\\'" move)))
+                    (chess-ply-keyword ply :long-castle)))
       (while (and (< i l) (< x xl))
        (let ((move-char (aref move i))
              (entry-char (aref chess-input-move-string x)))
-         (cond
-          ((or (and (= move-char ?x) (/= entry-char ?x))
-               (and (= move-char ?=) (/= entry-char ?=)))
-           (setq i (1+ i)))
-          ((/= entry-char (if (< entry-char ?a) move-char (downcase 
move-char)))
-           (setq ply nil i l))
-          (t (setq i (1+ i) x (1+ x)))))))
+         (cond ((or (and (= move-char ?x) (/= entry-char ?x))
+                    (and (= move-char ?=) (/= entry-char ?=)))
+                (setq i (1+ i)))
+               ((/= entry-char (if (< entry-char ?a)
+                                   move-char
+                                 (downcase move-char)))
+                (setq ply nil i l))
+               (t (setq i (1+ i) x (1+ x)))))))
     ply))
 
 (defun chess-input-display-moves (&optional move-list)
diff --git a/chess-ply.el b/chess-ply.el
index 907e8aa..5490013 100644
--- a/chess-ply.el
+++ b/chess-ply.el
@@ -104,11 +104,15 @@
          (throw 'found keyword)))))
 
 (defun chess-ply-keyword (ply keyword)
+  "Determine if PLY has KEYWORD.
+If KEYWORD can be found in the changes of PLY, the value
+directly following it is returned (as if it was part of a property list).
+If KEYWORD is the last element of the changes of ply, `t' is returned."
   (declare (side-effect-free t))
   (cl-check-type ply chess-ply)
   (cl-check-type keyword symbol)
   (let ((item (memq keyword (chess-ply-changes ply))))
-    (and item (if (not (cdr item)) t (cadr item)))))
+    (and item (if (cdr item) (cadr item) t))))
 
 (defun chess-ply-set-keyword (ply keyword &optional value)
   (cl-check-type ply chess-ply)



reply via email to

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