* .gitignore: Add ELPA's chess-autoloads.el and chess-pkg.el.
* chess-var.el:
* chess-test.el:
* chess-game.el:
* chess-eco.el: Don't require `cl'.
* chess-sound.el (chess-sound-handler): Remove unused var `text'.
* chess-puzzle.el (chess-display-handling-event): Declare.
* chess-pos.el (chess-pos-passed-pawns): Remove unused var `bias'.
(chess--add-candidate): Define as a macro rather than a defsubst so as
to avoid relying on dynamic scoping.
(chess-search-position): Remove unused var `p'.
* chess-polyglot.el (chess-polyglot-book-reload): Simplify, knowing
it's only used for chess-polyglot-book-file.
* chess-ply.el: Don't require `cl'.
(chess-ply--add): Define as a macro rather than a defsubst so as to
avoid relying on dynamic scoping.
* chess-plain.el (chess-plain-draw): Remove unused var `beg'.
* chess-pgn.el (chess-pgn-parse, chess-insert-pgn): Remove unused var
`begin'.
(chess-pgn-mode): Use make-local-variable instead of
make-variable-buffer-local.
(chess-pgn-index): Remove unused var `first-move'.
(chess-game-inhibit-events): Declare.
* chess-module.el: Don't require `cl'.
(chess-module-create): Remove unused var `buffer'.
* chess-kibitz.el (chess-module-game): Declare.
* chess-images.el (chess-images-popup): Remove unused var `display'.
(chess-images-highlight): Remove unused var `inverted'.
(chess-images-init-cache): Remove unused vars `backgrounds' and
`piece-colors'.
* chess-ics1.el (chess-ics1-draw): Remove unused var `beg'.
* chess-ics.el (chess-ics-handle-style12): Remove unused var `plies'.
* chess-engine.el (chess-full-name): Declare.
(chess-engine-filter): Remove unused var `last-point'.
* chess-display.el (chess-display-edit-position): Declare before
first use.
(chess-display-active-p): Define before first use.
(chess-display-search-backward): Remove unused var `err'.
(chess-images-separate-frame, ibuffer-maybe-show-regexps): Declare.
(chess-display-list-buffers): Use cl-letf.
(chess-display-mouse-select-piece): Use (featurep 'xemacs) and simplify.
* chess-crafty.el (chess-crafty-regexp-alist): Remove unused var
`nodes'.
* chess-algebraic.el: Don't require `cl'.
(chess-ply--move-text): Remove unused var `color'.
/TAGS
/auto-autoloads.el
/chess-auto.el
+/chess-autoloads.el
+/chess-pkg.el
/chess-test
/config.log
/config.status
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'chess-message)
(require 'chess-pos)
(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))
(chess-disable-autosave . "Disable autosaving for this game? ")
(autosave-available . "There is an autosave file; type ~ after connecting to read it")))
-(defun chess-autosave-handler (game event &rest args)
+(defun chess-autosave-handler (game event &rest _args)
(cond
((eq event 'initialize)
(kill-buffer (current-buffer))
(insert ")"))
(defun chess-autosave-write (game file)
- "Write a chess GAME to FILE as raw Lisp."
+ "Write a chess GAME to FILE as raw Lisp." ;FIXME: `file' is not used!
(let ((index (chess-game-index game)))
(if (or (= 1 index) (and (bobp) (eobp)))
(progn
(message nil)))
(defun chess-autosave-read (game file)
- "Read a chess game as raw Lisp from FILE."
+ "Read a chess game as raw Lisp from FILE." ;FIXME: `file' is not used!
(goto-char (point-min))
(chess-game-set-tags game (read (current-buffer)))
(let* ((plies (read (current-buffer)))
(set-marker chess-chat-input-last (point-max))
(set-buffer-modified-p nil))
-(defun chess-chat-handler (game event &rest args)
+(defun chess-chat-handler (_game event &rest args)
(cond
((eq event 'initialize)
(kill-buffer (current-buffer))
;; We can translate this information to EPD opcodes
(let ((depth (read (match-string 1)))
(centipawn (read (match-string 2)))
- (nodes (match-string 4))
(pos (chess-engine-position nil)))
(chess-pos-set-epd pos 'acd depth)
(chess-pos-set-epd pos 'ce centipawn)
(chess-game-set-data chess-module-game 'my-color t))
(chess-display-set-index nil 0)))
+(defvar chess-display-edit-position nil)
+(make-variable-buffer-local 'chess-display-edit-position)
+
(defun chess-display-position (display)
"Return the position currently viewed on DISPLAY."
(chess-with-current-buffer display
'((not-your-move . "It is not your turn to move")
(game-is-over . "This game is over")))
-(defun chess-display-move (display ply &optional prev-pos pos)
+(defsubst chess-display-active-p ()
+ "Return non-nil if the displayed chessboard reflects an active game.
+Basically, it means we are playing, not editing or reviewing."
+ (and (chess-game-data chess-module-game 'active)
+ (= chess-display-index
+ (chess-game-index chess-module-game))
+ (not (chess-game-over-p chess-module-game))
+ (not chess-display-edit-mode)))
+
+(defun chess-display-move (display ply &optional _prev-pos _pos)
"Move a piece on DISPLAY, by applying the given PLY.
The position of PLY must match the currently displayed position.
If only START is given, it must be in algebraic move notation."
;; Commands used by the keyboard bindings above
;;
-(defsubst chess-display-active-p ()
- "Return non-nil if the displayed chessboard reflects an active game.
-Basically, it means we are playing, not editing or reviewing."
- (and (chess-game-data chess-module-game 'active)
- (= chess-display-index
- (chess-game-index chess-module-game))
- (not (chess-game-over-p chess-module-game))
- (not chess-display-edit-mode)))
-
(defun chess-display-invert ()
"Invert the perspective of the current chess board."
(interactive)
(defun chess-display-search-backward (&optional direction)
(interactive)
(setq chess-display-previous-index chess-display-index)
- (condition-case err
+ (condition-case nil
(let ((chess-display-search-direction direction)
(chess-current-display (current-buffer)))
(read-from-minibuffer "Find algebraic move: " nil
(chess-error 'illegal-notation move))
(chess-display-move nil ply)))
+(defvar chess-images-separate-frame)
+
(defun chess-display-remote (display)
(interactive "sDisplay this game on X server: ")
(require 'chess-images)
(chess-game-run-hooks chess-module-game 'undo count))
(ding)))
+(defvar ibuffer-maybe-show-regexps)
+
(defun chess-display-list-buffers ()
- "List all buffers related to this display's current game."
+ "List all buffders related to this display's current game."
(interactive)
- (let ((buffer-list-func (symbol-function 'buffer-list)))
- (unwind-protect
- (let ((chess-game chess-module-game)
- (lb-command (lookup-key ctl-x-map [(control ?b)]))
- (ibuffer-maybe-show-regexps nil))
- (fset 'buffer-list
- (function
- (lambda (&optional frame)
- (delq nil
- (mapcar (function
- (lambda (cell)
- (and (bufferp (cdr cell))
- (buffer-live-p (cdr cell))
- (cdr cell))))
- (chess-game-hooks chess-game))))))
- (call-interactively lb-command))
- (fset 'buffer-list buffer-list-func))))
+ (let ((chess-game chess-module-game)
+ (lb-command (lookup-key ctl-x-map [(control ?b)]))
+ (ibuffer-maybe-show-regexps nil))
+ ;; FIXME: Running "whatever code is bound to `C-x b'" (which could really
+ ;; be anything, if the user is using a completely different key layout, as
+ ;; in Evil, ErgoEmacs, or whatnot) while rebinding buffer-list is
+ ;; pretty risky!
+ (cl-letf (((symbol-function 'buffer-list)
+ (lambda (&optional _frame)
+ (delq nil
+ (mapcar (function
+ (lambda (cell)
+ (and (bufferp (cdr cell))
+ (buffer-live-p (cdr cell))
+ (cdr cell))))
+ (chess-game-hooks chess-game))))))
+ (call-interactively lb-command))))
(chess-message-catalog 'english
'((return-to-current . "Use '>' to return to the current position")))
;; chess-display-edit-mode (for editing the position directly)
;;
-(defvar chess-display-edit-position nil)
-
-(make-variable-buffer-local 'chess-display-edit-position)
-
(defvar chess-display-edit-mode-map
(let ((map (make-keymap)))
(suppress-keymap map)
(defun chess-display-mouse-select-piece (event)
"Select the piece the user clicked on."
(interactive "e")
- (if (fboundp 'event-window) ; XEmacs
+ (if (featurep 'xemacs)
(progn
(set-buffer (window-buffer (event-window event)))
(and (event-point event) (goto-char (event-point event))))
- (if (equal (event-start event) (event-end event))
- (progn
- (set-buffer (window-buffer (posn-window (event-start event))))
- (goto-char (posn-point (event-start event))))
- (goto-char (posn-point (event-end event)))))
+ (set-buffer (window-buffer (posn-window (event-end event))))
+ (goto-char (posn-point (event-end event))))
(chess-display-select-piece))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; chess-eco.el --- Chess opening classification
-;; Copyright (C) 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2014 Free Software Foundation, Inc.
;; Author: Mario Lang <mlang@delysid.org>
;; Keywords: games
;;; Code:
-(eval-when-compile
- (require 'cl))
-
(require 'chess-game)
(require 'chess-ply)
(require 'chess-pos)
(chess-message-catalog 'english
'((announce-opening . "%s (ECO code %s)")))
-(defun chess-eco-handler (game event &rest args)
+(defun chess-eco-handler (game event &rest _args)
"Handle for the `chess-eco' module.
If you add `chess-eco' to `chess-default-modules', this handler will
try to figure out if the current position of a game does match a
(or (chess-pgn-to-game pgn)
(ignore (chess-message 'invalid-pgn))))
+(defvar chess-full-name)
+
(defun chess-engine-default-handler (event &rest args)
"Default engine response handler."
(let ((game (chess-engine-game nil)))
;; Primary event handler
;;
-(defun chess-engine-sentinel (proc event)
+(defun chess-engine-sentinel (proc _event)
(chess-engine-destroy (process-buffer proc)))
(defun chess-engine-filter (proc &optional string)
(process-buffer proc)
(current-buffer)))
(inhibit-redisplay t)
- last-point last-line-no-newline)
+ last-line-no-newline)
(when (buffer-live-p buf)
(with-current-buffer buf
(if (stringp proc)
;;; Code:
-(eval-when-compile
- (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'chess-ply)
(require 'chess-pgn)
index (chess-game-index game))))))
;; no preceeding ply supplied, so this is a starting position
(let ((chess-game-inhibit-events t)
- (color (chess-pos-side-to-move position))
- plies)
+ (color (chess-pos-side-to-move position)))
(when (or (= 1 status) (= -1 status))
(chess-game-set-data game 'my-color (if (= 1 status)
color (not color)))
;;; chess-ics1.el --- Classic ICS1 style chessboard display
-;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2005, 2014 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;; Keywords: games
(erase-buffer)
(let* ((inverted (not perspective))
(rank (if inverted 7 0))
- (file (if inverted 7 0)) beg)
+ (file (if inverted 7 0)))
(insert "\n +---+---+---+---+---+---+---+---+\n")
(while (if inverted (>= rank 0) (< rank 8))
(if (/= rank (if inverted 7 0))
(let* ((size (float (+ (* (or chess-images-border-width 0) 8)
(* chess-images-size 8))))
(max-char-height (ceiling (/ size (frame-char-height))))
- (max-char-width (ceiling (/ size (frame-char-width))))
- (display (and (stringp chess-images-separate-frame)
- chess-images-separate-frame)))
+ (max-char-width (ceiling (/ size (frame-char-width)))))
;; create the frame whenever necessary
(chess-display-popup-in-frame (+ max-char-height 2)
max-char-width
Common modes are:
`selected' show that the piece has been selected for movement.
`unselected' show that the piece has been unselected."
- (let* ((inverted (not (chess-display-perspective nil)))
- (pos (chess-display-index-pos nil index))
+ (let* ((pos (chess-display-index-pos nil index))
(highlight (copy-alist (get-text-property pos 'display))))
(setcar (last highlight)
(list (cons "light_square" (if (eq mode :selected)
nil nil nil nil))
(let* ((colors '("black" "white"))
- (backgrounds (list chess-images-dark-color
- chess-images-light-color))
- (piece-colors (list chess-images-black-color
- chess-images-white-color))
blank name image-data)
(dotimes (c 2)
(dotimes (b 2)
(let ((map (current-local-map)))
(define-key map [(control ?c) (control ?c)] 'chess-kibitz-save)))
+(defvar chess-module-game)
+
(defun chess-kibitz-save ()
(interactive)
(let ((ann (buffer-substring-no-properties chess-kibitz-input-last
;;; Code:
-(eval-when-compile
- (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'chess-game)
(defun chess-module-create (derived game &optional buffer-name
&rest ctor-args)
(let* ((name (symbol-name derived))
- handler buffer)
+ handler)
(unless (and (require derived nil t)
(setq handler (intern-soft (concat name "-handler"))))
(chess-error 'no-such-module name))
(if (or (looking-at "\\[")
(and (search-forward "[" nil t)
(goto-char (match-beginning 0))))
- (let ((game (chess-game-create))
- (begin (point)))
+ (let ((game (chess-game-create)))
(chess-game-set-tags game nil)
(while (looking-at "\\[\\(\\S-+\\)\\s-+\\(\".*?\"\\)\\][ \t\n\r]+")
(chess-game-set-tag game (match-string-no-properties 1)
(t (string-lessp left right))))))))
(insert (format "[%s \"%s\"]\n" (car tag) (cdr tag))))
(insert ?\n)
- (let ((begin (point)))
- (chess-pgn-insert-plies game 1 (chess-game-plies game))
- (insert (or (chess-game-tag game "Result") "*") ?\n)))
+ (chess-pgn-insert-plies game 1 (chess-game-plies game))
+ (insert (or (chess-game-tag game "Result") "*") ?\n))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
game)
(chess-error 'could-not-read-pgn))))
-(eval-after-load "pcomplete"
- '(progn
- (make-variable-buffer-local 'pcomplete-default-completion-function)
- (make-variable-buffer-local 'pcomplete-command-completion-function)
- (make-variable-buffer-local 'pcomplete-parse-arguments-function)))
-
;;;###autoload
(define-derived-mode chess-pgn-mode text-mode "PGN"
"A mode for editing chess PGN files."
(define-key map [? ] 'chess-pgn-insert-and-show-position)
(when (require 'pcomplete nil t)
- (setq pcomplete-default-completion-function 'chess-pgn-completions)
- (setq pcomplete-command-completion-function 'chess-pgn-completions)
- (setq pcomplete-parse-arguments-function 'chess-pgn-current-word)
+ (set (make-local-variable 'pcomplete-default-completion-function)
+ 'chess-pgn-completions)
+ (set (make-local-variable 'pcomplete-command-completion-function)
+ 'chess-pgn-completions)
+ (set (make-local-variable 'pcomplete-parse-arguments-function)
+ 'chess-pgn-current-word)
(define-key map [tab] 'chess-pgn-complete-move))))
;;;###autoload
(when location (goto-char location))
(if (re-search-backward chess-pgn-move-regexp nil t)
(let* ((index (string-to-number (match-string 2)))
- (first-move (match-string 3))
+ ;; (first-move (match-string 3))
(second-move (match-string 14))
(ply (1+ (* 2 (1- index)))))
(if second-move
(setq chess-pgn-current-game
(chess-database-read chess-pgn-database index))))))
+(defvar chess-game-inhibit-events)
+
(defun chess-pgn-create-display ()
"Return the move index associated with point."
;; now find what position we're at in the game
(erase-buffer)
(let* ((inverted (not perspective))
(rank (if inverted 7 0))
- (file (if inverted 7 0)) beg)
+ (file (if inverted 7 0)))
(when chess-plain-border-style
(insert ? (aref chess-plain-border-style 0)
(make-string (+ 8 (* 7 chess-plain-spacing))
;;; Code:
-(eval-when-compile
- (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'chess-pos)
(require 'chess-algebraic)
(chess-ply-any-keyword (chess-pos-preceding-ply
(chess-ply-pos ply)) :stalemate :checkmate)))
-(eval-when-compile
- (defvar position)
- (defvar candidate)
- (defvar color)
- (defvar plies)
- (defvar specific-target))
-
(defvar chess-ply-throw-if-any nil)
-(defsubst chess-ply--add (rank-adj file-adj &optional pos)
+(defmacro chess-ply--add (rank-adj file-adj &optional pos)
"This is totally a shortcut."
- (let ((target (or pos (chess-incr-index candidate rank-adj file-adj))))
+ `(let ((target (or ,pos (chess-incr-index candidate ,rank-adj ,file-adj))))
(if (and (or (not specific-target)
(= target specific-target))
(chess-pos-legal-candidates position color target
;; pawn movement, which is diagonal 1 when taking, but forward
;; 1 or 2 when moving (the most complex piece, actually)
((= test-piece ?P)
- (let* ((bias (if color -1 1))
- (ahead (chess-next-index candidate (if color
+ (let* ((ahead (chess-next-index candidate (if color
chess-direction-north
chess-direction-south)))
(2ahead (when ahead (chess-next-index ahead (if color
(defun chess-polyglot-book-reload (symbol value)
(set symbol value)
- (when (eq symbol 'chess-polyglot-book-file)
- (setq chess-polyglot-book
- (when chess-polyglot-book-file
- (chess-polyglot-book-open chess-polyglot-book-file)))))
+ (setq chess-polyglot-book
+ (when value (chess-polyglot-book-open value))))
(defcustom chess-polyglot-book-file (expand-file-name "chess-polyglot.bin"
(file-name-directory
A Pawn whose advance to the eighth rank is not blocked by an
opposing Pawn in the same file and who does not have to pass one
on an adjoining file is called a passed Pawn."
- (let ((seventh (if color 1 6)) (bias (if color -1 1)) (pawn (if color ?p ?P))
+ (let ((seventh (if color 1 6)) (pawn (if color ?p ?P))
pawns)
(dolist (index (or pawn-indices
(chess-pos-search position (if color ?P ?p))) pawns)
(chess-message-catalog 'english
'((piece-unrecognized . "Unrecognized piece identifier")))
-(eval-when-compile
- (defvar candidates)
- (defvar check-only))
-
-(defsubst chess--add-candidate (candidate)
- (if check-only
- (throw 'in-check t)
- (push candidate candidates)))
+(defmacro chess--add-candidate (candidate)
+ `(if check-only
+ (throw 'in-check t)
+ (push ,candidate candidates)))
(defconst chess-white-can-slide-to
(let ((squares (make-vector 64 nil)))
piece))
(test-piece (and (characterp piece)
(upcase piece)))
- p pos candidates)
+ pos candidates)
(cond
;; if the piece is `t', it means to find the candidates resulting
;; from any piece movement. This is useful for testing whether a
;;; chess-puzzle.el --- Support for viewing and solving chess puzzles
-;; Copyright (C) 2002, 2004, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2008, 2014 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;; Maintainer: Mario Lang <mlang@delysid.org>
(end-of-puzzles . "There are no more puzzles in this collection")))
;;;###autoload
-(defun chess-puzzle (file &optional index)
+(defun chess-puzzle (file &optional index) ;FIXME: index not used!
"Pick a random puzzle from FILE, and solve it against the default engine.
The spacebar in the display buffer is bound to `chess-puzzle-next',
making it easy to go on to the next puzzle once you've solved one."
(chess-game-run-hooks (chess-display-game display) 'disable-autosave)
(chess-puzzle-next)))))
+(defvar chess-display-handling-event)
+
(defun chess-puzzle-next ()
"Play the next puzzle in the collection, selected randomly."
(interactive)
"")))))))
-(defun chess-puzzle-handler (game display event &rest args)
+(defun chess-puzzle-handler (game display event &rest _args)
(if (and (eq event 'move)
(chess-game-over-p game))
(with-current-buffer display
;;; chess-sound.el --- Announce chess moves with pre-recorded sound files
-;; Copyright (C) 2002, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2008, 2014 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;; Maintainer: Mario Lang <mlang@delysid.org>
(apply 'call-process chess-sound-program
nil nil nil (append chess-sound-args (list file))))
-(defun chess-sound-handler (game event &rest args)
+(defun chess-sound-handler (game event &rest _args)
(cond
((eq event 'initialize)
(and (file-directory-p chess-sound-directory)
(target (chess-ply-target ply))
(s-piece (and source (chess-pos-piece pos source)))
(t-piece (and target (chess-pos-piece pos target)))
- (which (chess-ply-keyword ply :which))
- text)
+ (which (chess-ply-keyword ply :which)))
(cond
((chess-ply-keyword ply :castle)
(chess-sound "O-O"))
;;; Code:
-(eval-when-compile
- (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'chess-database)
(require 'chess-game)
(knight-1-done . "Goal: take all the pawns, without letting the queen take your knight")
(cannot-take-queen . "You cannot take the queen")))
-(defun chess-tutorial-knight-1 (game ignore event &rest args)
+(defun chess-tutorial-knight-1 (game _ignore event &rest _args)
(if (eq event 'move)
(let ((position (chess-game-pos game)))
(if (null (chess-pos-search position ?p))
;;; Code:
(require 'chess-ply)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defsubst chess-var-plies (var)
"Return the plies of VAR."