]> code.delx.au - gnu-emacs/blobdiff - lisp/play/gamegrid.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / play / gamegrid.el
index da10ffaf0a5aaf5b1e6175cbe6f47278b7985b57..eefe1e22599697afc357509bcdacb8f7390efda2 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, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <glynn@sensei.co.uk>
 ;; Version: 1.02
@@ -27,9 +26,6 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
-
 ;; ;;;;;;;;;;;;; buffer-local variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defvar gamegrid-use-glyphs t
@@ -179,7 +175,7 @@ static unsigned char gamegrid_bits[] = {
 
 (defun gamegrid-make-mono-tty-face ()
   (let ((face (make-face 'gamegrid-mono-tty-face)))
-    (set-face-inverse-video-p face t)
+    (set-face-inverse-video face t)
     face))
 
 (defun gamegrid-make-color-tty-face (color)
@@ -213,20 +209,20 @@ static unsigned char gamegrid_bits[] = {
 (defun gamegrid-make-face (data-spec-list color-spec-list)
   (let ((data (gamegrid-match-spec-list data-spec-list))
        (color (gamegrid-match-spec-list color-spec-list)))
-    (case data
-      ('color-x
+    (pcase data
+      (`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))))
@@ -312,13 +308,13 @@ static unsigned char gamegrid_bits[] = {
                   (intern (concat "gamegrid-face-" (buffer-name)))))
   (when (eq gamegrid-display-mode 'glyph)
     (let ((max-height nil))
-      (loop for c from 0 to 255 do
-           (let ((glyph (aref gamegrid-display-table c)))
-             (when (and (listp glyph) (eq (car  glyph) 'image))
-               (let ((height (cdr (image-size glyph))))
-                 (if (or (null max-height)
-                         (< max-height height))
-                     (setq max-height height))))))
+      (dotimes (c 256)
+        (let ((glyph (aref gamegrid-display-table c)))
+          (when (and (listp glyph) (eq (car  glyph) 'image))
+            (let ((height (cdr (image-size glyph))))
+              (if (or (null max-height)
+                      (< max-height height))
+                  (setq max-height height))))))
       (when (and max-height (< max-height 1))
        (let ((default-font-height (face-attribute 'default :height))
              (resy (/ (display-pixel-height) (/ (display-mm-height) 25.4)))
@@ -333,10 +329,10 @@ static unsigned char gamegrid_bits[] = {
   (setq gamegrid-display-mode (gamegrid-display-type))
   (setq gamegrid-display-table (make-display-table))
   (setq gamegrid-face-table (make-vector 256 nil))
-  (loop for c from 0 to 255 do
+  (dotimes (c 256)
     (let* ((spec (aref gamegrid-display-options c))
-          (glyph (gamegrid-make-glyph (car spec) (caddr spec)))
-          (face (gamegrid-make-face (cadr spec) (caddr spec))))
+          (glyph (gamegrid-make-glyph (car spec) (nth 2 spec)))
+          (face (gamegrid-make-face (cadr spec) (nth 2 spec))))
       (aset gamegrid-face-table c face)
       (aset gamegrid-display-table c glyph)))
   (gamegrid-setup-default-font)
@@ -452,10 +448,10 @@ 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,
 FILE is created there."
-  (case system-type
-    ((ms-dos windows-nt)
+  (pcase system-type
+    ((or `ms-dos `windows-nt)
      (gamegrid-add-score-insecure file score))
-    (t
+    (_
      (gamegrid-add-score-with-update-game-score file score))))
 
 
@@ -486,12 +482,11 @@ FILE is created there."
 (defvar gamegrid-shared-game-dir)
 
 (defun gamegrid-add-score-with-update-game-score (file score)
-  (let* ((result nil) ;; What is this good for? -- os
-        (gamegrid-shared-game-dir
-         (not (zerop (logand (file-modes
-                              (expand-file-name "update-game-score"
-                                                exec-directory))
-                             #o4000)))))
+  (let ((gamegrid-shared-game-dir
+        (not (zerop (logand (file-modes
+                             (expand-file-name "update-game-score"
+                                               exec-directory))
+                            #o4000)))))
     (cond ((file-name-absolute-p file)
           (gamegrid-add-score-insecure file score))
          ((and gamegrid-shared-game-dir
@@ -565,7 +560,7 @@ FILE is created there."
         (goto-char (point-min))
         (search-forward (concat (int-to-string score)
                                " " (user-login-name) " "
-                               marker-string))
+                               marker-string) nil t)
         (beginning-of-line)))))
 
 (defun gamegrid-add-score-insecure (file score &optional directory)
@@ -597,5 +592,4 @@ FILE is created there."
 
 (provide 'gamegrid)
 
-;; arch-tag: a96c2ff4-1c12-427e-bd3d-faeaf174cd46
 ;;; gamegrid.el ends here