X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/d2fc7e3d0f6f57f962cbd94df3bf4fd15a37bb68..b687d65a02e93fda36a00e90bd016a0f74f9708e:/lisp/play/gamegrid.el diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index e245e70a55..b6fd064ca8 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -1,6 +1,6 @@ ;;; gamegrid.el --- library for implementing grid-based games on Emacs -;; Copyright (C) 1997-1998, 2001-2011 Free Software Foundation, Inc. +;; Copyright (C) 1997-1998, 2001-2013 Free Software Foundation, Inc. ;; Author: Glynn Clements ;; Version: 1.02 @@ -26,9 +26,6 @@ ;;; Code: -(eval-when-compile - (require 'cl)) - ;; ;;;;;;;;;;;;; buffer-local variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar gamegrid-use-glyphs t @@ -178,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) @@ -212,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)))) @@ -311,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))) @@ -332,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) @@ -451,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)))) @@ -508,16 +505,15 @@ FILE is created there." (make-directory gamegrid-user-score-file-directory t)) (gamegrid-add-score-insecure file score gamegrid-user-score-file-directory)) - (t (let ((f (expand-file-name - gamegrid-user-score-file-directory))) - (when (file-writable-p f) - (unless (eq (car-safe (file-attributes f)) - t) - (make-directory f)) - (setq f (expand-file-name file f)) - (unless (file-exists-p f) - (write-region "" nil f nil 'silent nil 'excl))) - (gamegrid-add-score-with-update-game-score-1 file f score)))))) + (t + (unless (file-exists-p + (directory-file-name gamegrid-user-score-file-directory)) + (make-directory gamegrid-user-score-file-directory t)) + (let ((f (expand-file-name file + gamegrid-user-score-file-directory))) + (unless (file-exists-p f) + (write-region "" nil f nil 'silent nil 'excl)) + (gamegrid-add-score-with-update-game-score-1 file f score)))))) (defun gamegrid-add-score-with-update-game-score-1 (file target score) (let ((default-directory "/") @@ -563,7 +559,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)