-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Basic module support code underlying all chess.el modules
-;;
-;; $Revision$
+;;; chess-module.el --- Basic module support code underlying all chess.el modules
+
+;; Copyright (C) 2002, 2004, 2008, 2014 Free Software Foundation, Inc.
+
+;; Author: John Wiegley <johnw@gnu.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/>.
+
+;;; Code:
+
+(eval-when-compile (require 'cl-lib))
(require 'chess-game)
,@body)
,@body)))
+(put 'chess-with-current-buffer 'lisp-indent-function 1)
+
(defun chess-module-create (derived game &optional buffer-name
&rest ctor-args)
(let* ((name (symbol-name derived))
- (handler (intern-soft (concat name "-handler")))
- buffer)
- (unless handler
+ handler)
+ (unless (and (require derived nil t)
+ (setq handler (intern-soft (concat name "-handler"))))
(chess-error 'no-such-module name))
(with-current-buffer (generate-new-buffer (or buffer-name
(format " *%s*" name)))
(defun chess-module-set-game* (module game)
(chess-with-current-buffer module
- (assert game)
+ (cl-assert game)
(if chess-module-game
(chess-module-detach-game nil))
(setq chess-module-game game)
(let ((buf (or module (current-buffer))))
(when (buffer-live-p buf)
(with-current-buffer buf
- (remove-hook 'kill-buffer-hook 'chess-module-destroy t))
- (chess-module-detach-game nil)
+ (remove-hook 'kill-buffer-hook 'chess-module-destroy t)
+ (chess-module-detach-game nil))
(kill-buffer buf))))
(defun chess-module-event-handler (game object event &rest args)