Merge from trunk
[bpt/emacs.git] / lisp / play / gamegrid.el
index 5854855..99e3b48 100644 (file)
@@ -1,7 +1,6 @@
 ;;; gamegrid.el --- library for implementing grid-based games on Emacs
 
-;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2011  Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <glynn@sensei.co.uk>
 ;; Version: 1.02
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs 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, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 (defvar gamegrid-buffer-start 1)
 
 (defvar gamegrid-score-file-length 50
-  "Number of high scores to keep")
+  "Number of high scores to keep.")
 
 (defvar gamegrid-user-score-file-directory
-  (concat user-emacs-directory "games")
+  (locate-user-emacs-file "games/")
   "A directory for game scores which can't be shared.
 If Emacs was built without support for shared game scores, then this
 directory will be used.")
@@ -216,19 +213,19 @@ static unsigned char gamegrid_bits[] = {
   (let ((data (gamegrid-match-spec-list data-spec-list))
        (color (gamegrid-match-spec-list color-spec-list)))
     (case data
-      ('color-x
+      (color-x
        (gamegrid-make-color-x-face color))
-      ('grid-x
+      (grid-x
        (unless gamegrid-grid-x-face
         (setq gamegrid-grid-x-face (gamegrid-make-grid-x-face)))
        gamegrid-grid-x-face)
-      ('mono-x
+      (mono-x
        (unless gamegrid-mono-x-face
         (setq gamegrid-mono-x-face (gamegrid-make-mono-x-face)))
        gamegrid-mono-x-face)
-      ('color-tty
+      (color-tty
        (gamegrid-make-color-tty-face color))
-      ('mono-tty
+      (mono-tty
        (unless gamegrid-mono-tty-face
         (setq gamegrid-mono-tty-face (gamegrid-make-mono-tty-face)))
        gamegrid-mono-tty-face))))
@@ -306,6 +303,8 @@ static unsigned char gamegrid_bits[] = {
                             'remove-locale)
     (setq buffer-display-table gamegrid-display-table)))
 
+(declare-function image-size "image.c" (spec &optional pixels frame))
+
 (defun gamegrid-setup-default-font ()
   (setq gamegrid-face
        (copy-face 'default
@@ -438,19 +437,19 @@ static unsigned char gamegrid_bits[] = {
   "Add the current score to the high score file.
 
 On POSIX systems there may be a shared game directory for all users in
-which the scorefiles are kept. On such systems Emacs doesn't create
-the score file FILE in this directory, if it doesn't already exist. In
-this case Emacs searches for FILE in the directory specified by
+which the scorefiles are kept.  On such systems Emacs doesn't create
+the score file FILE in this directory, if it doesn't already exist.
+In this case Emacs searches for FILE in the directory specified by
 `gamegrid-user-score-file-directory' and creates it there, if
 necessary.
 
 To add the score file for a game to the system wide shared game
 directory, create the file with the shell command \"touch\" in this
 directory and make sure that it is owned by the correct user and
-group. You probably need special user privileges to do this.
+group.  You probably need special user privileges to do this.
 
 On non-POSIX systems Emacs searches for FILE in the directory
-specified by the variable `temporary-file-directory'. If necessary,
+specified by the variable `temporary-file-directory'.  If necessary,
 FILE is created there."
   (case system-type
     ((ms-dos windows-nt)
@@ -586,7 +585,8 @@ FILE is created there."
                          (t ""))))
     (sort-fields 1 (point-min) (point-max))
     (reverse-region (point-min) (point-max))
-    (goto-line (1+ gamegrid-score-file-length))
+    (goto-char (point-min))
+    (forward-line gamegrid-score-file-length)
     (delete-region (point) (point-max))
     (setq buffer-read-only t)
     (save-buffer)))
@@ -596,5 +596,4 @@ FILE is created there."
 
 (provide 'gamegrid)
 
-;; arch-tag: a96c2ff4-1c12-427e-bd3d-faeaf174cd46
 ;;; gamegrid.el ends here