2001-07-16 09:10:19 +00:00
|
|
|
;;; gamegrid.el --- library for implementing grid-based games on Emacs
|
1998-06-14 21:32:23 +00:00
|
|
|
|
2012-01-05 09:46:05 +00:00
|
|
|
;; Copyright (C) 1997-1998, 2001-2012 Free Software Foundation, Inc.
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
;; Author: Glynn Clements <glynn@sensei.co.uk>
|
|
|
|
;; Version: 1.02
|
|
|
|
;; Created: 1997-08-13
|
|
|
|
;; Keywords: games
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1998-06-14 21:32:23 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2008-05-06 07:25:26 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2001-07-16 09:10:19 +00:00
|
|
|
;;; Code:
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
;; ;;;;;;;;;;;;; buffer-local variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defvar gamegrid-use-glyphs t
|
|
|
|
"Non-nil means use glyphs when available.")
|
|
|
|
|
|
|
|
(defvar gamegrid-use-color t
|
|
|
|
"Non-nil means use color when available.")
|
|
|
|
|
|
|
|
(defvar gamegrid-font "-*-courier-medium-r-*-*-*-140-100-75-*-*-iso8859-*"
|
|
|
|
"Name of the font used in X mode.")
|
|
|
|
|
2002-09-23 16:03:03 +00:00
|
|
|
(defvar gamegrid-face nil
|
|
|
|
"Indicates the face to use as a default.")
|
|
|
|
(make-variable-buffer-local 'gamegrid-face)
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
(defvar gamegrid-display-options nil)
|
|
|
|
|
|
|
|
(defvar gamegrid-buffer-width 0)
|
|
|
|
(defvar gamegrid-buffer-height 0)
|
|
|
|
(defvar gamegrid-blank 0)
|
|
|
|
|
|
|
|
(defvar gamegrid-timer nil)
|
|
|
|
|
|
|
|
(defvar gamegrid-display-mode nil)
|
|
|
|
|
|
|
|
(defvar gamegrid-display-table)
|
|
|
|
|
|
|
|
(defvar gamegrid-face-table nil)
|
|
|
|
|
|
|
|
(defvar gamegrid-buffer-start 1)
|
|
|
|
|
|
|
|
(defvar gamegrid-score-file-length 50
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
"Number of high scores to keep.")
|
1998-06-14 21:32:23 +00:00
|
|
|
|
2007-06-13 00:05:37 +00:00
|
|
|
(defvar gamegrid-user-score-file-directory
|
2008-10-24 09:39:27 +00:00
|
|
|
(locate-user-emacs-file "games/")
|
2002-05-03 19:30:58 +00:00
|
|
|
"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.")
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
(make-variable-buffer-local 'gamegrid-use-glyphs)
|
|
|
|
(make-variable-buffer-local 'gamegrid-use-color)
|
|
|
|
(make-variable-buffer-local 'gamegrid-font)
|
|
|
|
(make-variable-buffer-local 'gamegrid-display-options)
|
|
|
|
(make-variable-buffer-local 'gamegrid-buffer-width)
|
|
|
|
(make-variable-buffer-local 'gamegrid-buffer-height)
|
|
|
|
(make-variable-buffer-local 'gamegrid-blank)
|
|
|
|
(make-variable-buffer-local 'gamegrid-timer)
|
|
|
|
(make-variable-buffer-local 'gamegrid-display-mode)
|
|
|
|
(make-variable-buffer-local 'gamegrid-display-table)
|
|
|
|
(make-variable-buffer-local 'gamegrid-face-table)
|
|
|
|
(make-variable-buffer-local 'gamegrid-buffer-start)
|
|
|
|
(make-variable-buffer-local 'gamegrid-score-file-length)
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;; global variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defvar gamegrid-grid-x-face nil)
|
|
|
|
(defvar gamegrid-mono-x-face nil)
|
|
|
|
(defvar gamegrid-mono-tty-face nil)
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defconst gamegrid-glyph-height 16)
|
|
|
|
|
|
|
|
(defconst gamegrid-xpm "\
|
|
|
|
/* XPM */
|
|
|
|
static char *noname[] = {
|
|
|
|
/* width height ncolors chars_per_pixel */
|
|
|
|
\"16 16 3 1\",
|
|
|
|
/* colors */
|
|
|
|
\"+ s col1\",
|
|
|
|
\". s col2\",
|
|
|
|
\"- s col3\",
|
|
|
|
/* pixels */
|
|
|
|
\"---------------+\",
|
|
|
|
\"--------------++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"--............++\",
|
|
|
|
\"-+++++++++++++++\",
|
|
|
|
\"++++++++++++++++\"
|
|
|
|
};
|
|
|
|
"
|
|
|
|
"XPM format image used for each square")
|
|
|
|
|
2002-09-23 16:03:03 +00:00
|
|
|
(defvar gamegrid-xbm "\
|
|
|
|
/* gamegrid XBM */
|
|
|
|
#define gamegrid_width 16
|
|
|
|
#define gamegrid_height 16
|
|
|
|
static unsigned char gamegrid_bits[] = {
|
|
|
|
0xff, 0xff, 0xff, 0x7f, 0xff, 0x3f, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a,
|
|
|
|
0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a,
|
|
|
|
0x57, 0x15, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00 };"
|
|
|
|
"XBM format image used for each square.")
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
;; ;;;;;;;;;;;;;;;; miscellaneous functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defsubst gamegrid-characterp (arg)
|
|
|
|
(if (fboundp 'characterp)
|
|
|
|
(characterp arg)
|
|
|
|
(integerp arg)))
|
|
|
|
|
|
|
|
(defsubst gamegrid-event-x (event)
|
|
|
|
(if (fboundp 'event-x)
|
|
|
|
(event-x event)
|
|
|
|
(car (posn-col-row (event-end event)))))
|
|
|
|
|
|
|
|
(defsubst gamegrid-event-y (event)
|
|
|
|
(if (fboundp 'event-y)
|
|
|
|
(event-y event)
|
|
|
|
(cdr (posn-col-row (event-end event)))))
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;; display functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun gamegrid-color (color shade)
|
|
|
|
(let* ((v (floor (* shade 255)))
|
|
|
|
(r (* v (aref color 0)))
|
|
|
|
(g (* v (aref color 1)))
|
|
|
|
(b (* v (aref color 2))))
|
|
|
|
(format "#%02x%02x%02x" r g b)))
|
|
|
|
|
|
|
|
(defun gamegrid-set-font (face)
|
|
|
|
(if gamegrid-font
|
|
|
|
(condition-case nil
|
|
|
|
(set-face-font face gamegrid-font)
|
2002-03-03 14:14:38 +00:00
|
|
|
(error nil))))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-setup-face (face color)
|
|
|
|
(set-face-foreground face color)
|
|
|
|
(set-face-background face color)
|
|
|
|
(gamegrid-set-font face)
|
|
|
|
(condition-case nil
|
|
|
|
(set-face-background-pixmap face [nothing]);; XEmacs
|
2002-03-03 14:14:38 +00:00
|
|
|
(error nil))
|
1998-06-14 21:32:23 +00:00
|
|
|
(condition-case nil
|
|
|
|
(set-face-background-pixmap face nil);; Emacs
|
2002-03-03 14:14:38 +00:00
|
|
|
(error nil)))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-make-mono-tty-face ()
|
|
|
|
(let ((face (make-face 'gamegrid-mono-tty-face)))
|
2012-11-21 08:27:13 +00:00
|
|
|
(set-face-inverse-video face t)
|
1998-06-14 21:32:23 +00:00
|
|
|
face))
|
|
|
|
|
|
|
|
(defun gamegrid-make-color-tty-face (color)
|
2002-09-10 16:47:16 +00:00
|
|
|
(let* ((color-str (if (symbolp color) (symbol-value color) color))
|
2002-02-06 11:34:07 +00:00
|
|
|
(name (intern (format "gamegrid-color-tty-face-%s" color-str)))
|
1998-06-14 21:32:23 +00:00
|
|
|
(face (make-face name)))
|
2002-02-06 11:34:07 +00:00
|
|
|
(gamegrid-setup-face face color-str)
|
1998-06-14 21:32:23 +00:00
|
|
|
face))
|
|
|
|
|
|
|
|
(defun gamegrid-make-grid-x-face ()
|
|
|
|
(let ((face (make-face 'gamegrid-x-border-face)))
|
|
|
|
(gamegrid-set-font face)
|
|
|
|
face))
|
|
|
|
|
|
|
|
(defun gamegrid-make-mono-x-face ()
|
|
|
|
(let ((face (make-face 'gamegrid-mono-x-face))
|
|
|
|
(color (face-foreground 'default)))
|
|
|
|
(if (null color)
|
|
|
|
(setq color
|
|
|
|
(cdr-safe (assq 'foreground-color (frame-parameters)))))
|
|
|
|
(gamegrid-setup-face face color)
|
|
|
|
face))
|
|
|
|
|
|
|
|
(defun gamegrid-make-color-x-face (color)
|
|
|
|
(let* ((hex (gamegrid-color color 1.0))
|
|
|
|
(name (intern (format "gamegrid-color-x-face-%s" hex)))
|
|
|
|
(face (make-face name)))
|
2002-02-06 11:34:07 +00:00
|
|
|
(gamegrid-setup-face face hex)
|
1998-06-14 21:32:23 +00:00
|
|
|
face))
|
|
|
|
|
|
|
|
(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)))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(pcase data
|
|
|
|
(`color-x
|
1998-06-14 21:32:23 +00:00
|
|
|
(gamegrid-make-color-x-face color))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(`grid-x
|
1998-06-14 21:32:23 +00:00
|
|
|
(unless gamegrid-grid-x-face
|
|
|
|
(setq gamegrid-grid-x-face (gamegrid-make-grid-x-face)))
|
|
|
|
gamegrid-grid-x-face)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(`mono-x
|
1998-06-14 21:32:23 +00:00
|
|
|
(unless gamegrid-mono-x-face
|
|
|
|
(setq gamegrid-mono-x-face (gamegrid-make-mono-x-face)))
|
|
|
|
gamegrid-mono-x-face)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(`color-tty
|
1998-06-14 21:32:23 +00:00
|
|
|
(gamegrid-make-color-tty-face color))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(`mono-tty
|
1998-06-14 21:32:23 +00:00
|
|
|
(unless gamegrid-mono-tty-face
|
|
|
|
(setq gamegrid-mono-tty-face (gamegrid-make-mono-tty-face)))
|
|
|
|
gamegrid-mono-tty-face))))
|
|
|
|
|
|
|
|
(defun gamegrid-colorize-glyph (color)
|
2002-09-23 16:03:03 +00:00
|
|
|
(find-image `((:type xpm :data ,gamegrid-xpm
|
|
|
|
:ascent center
|
2003-02-04 13:24:35 +00:00
|
|
|
:color-symbols
|
2002-09-23 16:03:03 +00:00
|
|
|
(("col1" . ,(gamegrid-color color 0.6))
|
|
|
|
("col2" . ,(gamegrid-color color 0.8))
|
|
|
|
("col3" . ,(gamegrid-color color 1.0))))
|
|
|
|
(:type xbm :data ,gamegrid-xbm
|
|
|
|
:ascent center
|
|
|
|
:foreground ,(gamegrid-color color 1.0)
|
|
|
|
:background ,(gamegrid-color color 0.5)))))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-match-spec (spec)
|
|
|
|
(let ((locale (car spec))
|
|
|
|
(value (cadr spec)))
|
|
|
|
(and (or (eq locale t)
|
|
|
|
(and (listp locale)
|
|
|
|
(memq gamegrid-display-mode locale))
|
|
|
|
(and (symbolp locale)
|
|
|
|
(eq gamegrid-display-mode locale)))
|
|
|
|
value)))
|
|
|
|
|
|
|
|
(defun gamegrid-match-spec-list (spec-list)
|
|
|
|
(and spec-list
|
|
|
|
(or (gamegrid-match-spec (car spec-list))
|
|
|
|
(gamegrid-match-spec-list (cdr spec-list)))))
|
|
|
|
|
|
|
|
(defun gamegrid-make-glyph (data-spec-list color-spec-list)
|
|
|
|
(let ((data (gamegrid-match-spec-list data-spec-list))
|
|
|
|
(color (gamegrid-match-spec-list color-spec-list)))
|
|
|
|
(cond ((gamegrid-characterp data)
|
|
|
|
(vector data))
|
|
|
|
((eq data 'colorize)
|
|
|
|
(gamegrid-colorize-glyph color))
|
2002-09-23 16:03:03 +00:00
|
|
|
((listp data)
|
|
|
|
(find-image data)) ;untested!
|
1998-06-14 21:32:23 +00:00
|
|
|
((vectorp data)
|
2002-09-23 16:03:03 +00:00
|
|
|
(gamegrid-make-image-from-vector data)))))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
2002-09-23 16:03:03 +00:00
|
|
|
(defun gamegrid-make-image-from-vector (vect)
|
|
|
|
"Convert an XEmacs style \"glyph\" to an image-spec."
|
|
|
|
(let ((l (list 'image :type)))
|
|
|
|
(dotimes (n (length vect))
|
|
|
|
(setf l (nconc l (list (aref vect n)))))
|
|
|
|
(nconc l (list :ascent 'center))))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-display-type ()
|
2002-09-23 16:03:03 +00:00
|
|
|
(cond ((and gamegrid-use-glyphs
|
|
|
|
(display-images-p))
|
|
|
|
'glyph)
|
|
|
|
((and gamegrid-use-color
|
|
|
|
(display-graphic-p)
|
|
|
|
(display-color-p))
|
|
|
|
'color-x)
|
|
|
|
((display-graphic-p)
|
|
|
|
'mono-x)
|
|
|
|
((and gamegrid-use-color
|
|
|
|
(display-color-p))
|
|
|
|
'color-tty)
|
|
|
|
((display-multi-font-p) ;???
|
|
|
|
'mono-tty)
|
|
|
|
(t
|
|
|
|
'emacs-tty)))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-set-display-table ()
|
2005-07-16 18:34:22 +00:00
|
|
|
(if (featurep 'xemacs)
|
1998-06-14 21:32:23 +00:00
|
|
|
(add-spec-to-specifier current-display-table
|
|
|
|
gamegrid-display-table
|
|
|
|
(current-buffer)
|
|
|
|
nil
|
|
|
|
'remove-locale)
|
|
|
|
(setq buffer-display-table gamegrid-display-table)))
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
(declare-function image-size "image.c" (spec &optional pixels frame))
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
(defun gamegrid-setup-default-font ()
|
2002-09-23 16:03:03 +00:00
|
|
|
(setq gamegrid-face
|
|
|
|
(copy-face 'default
|
|
|
|
(intern (concat "gamegrid-face-" (buffer-name)))))
|
|
|
|
(when (eq gamegrid-display-mode 'glyph)
|
|
|
|
(let ((max-height nil))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(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))))))
|
2002-09-23 16:03:03 +00:00
|
|
|
(when (and max-height (< max-height 1))
|
2007-08-23 12:13:24 +00:00
|
|
|
(let ((default-font-height (face-attribute 'default :height))
|
|
|
|
(resy (/ (display-pixel-height) (/ (display-mm-height) 25.4)))
|
|
|
|
point-size pixel-size)
|
|
|
|
(setq point-size (/ (* (float default-font-height) max-height) 10)
|
|
|
|
pixel-size (floor (* resy (/ point-size 72.27)))
|
|
|
|
point-size (* (/ pixel-size resy) 72.27))
|
2007-10-11 16:24:58 +00:00
|
|
|
(face-spec-set gamegrid-face
|
|
|
|
`((t :height ,(floor (* point-size 10))))))))))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
(defun gamegrid-initialize-display ()
|
|
|
|
(setq gamegrid-display-mode (gamegrid-display-type))
|
|
|
|
(setq gamegrid-display-table (make-display-table))
|
|
|
|
(setq gamegrid-face-table (make-vector 256 nil))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(dotimes (c 256)
|
1998-06-14 21:32:23 +00:00
|
|
|
(let* ((spec (aref gamegrid-display-options c))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(glyph (gamegrid-make-glyph (car spec) (nth 2 spec)))
|
|
|
|
(face (gamegrid-make-face (cadr spec) (nth 2 spec))))
|
1998-06-14 21:32:23 +00:00
|
|
|
(aset gamegrid-face-table c face)
|
|
|
|
(aset gamegrid-display-table c glyph)))
|
|
|
|
(gamegrid-setup-default-font)
|
|
|
|
(gamegrid-set-display-table)
|
2002-09-23 16:03:03 +00:00
|
|
|
(setq cursor-type nil))
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun gamegrid-set-face (c)
|
2002-09-23 16:03:03 +00:00
|
|
|
(if (eq gamegrid-display-mode 'glyph)
|
|
|
|
(add-text-properties (1- (point)) (point)
|
|
|
|
(list 'display (list (aref gamegrid-display-table c))))
|
1998-06-14 21:32:23 +00:00
|
|
|
(put-text-property (1- (point))
|
|
|
|
(point)
|
|
|
|
'face
|
|
|
|
(aref gamegrid-face-table c))))
|
|
|
|
|
|
|
|
(defun gamegrid-cell-offset (x y)
|
|
|
|
(+ gamegrid-buffer-start
|
|
|
|
(* (1+ gamegrid-buffer-width) y)
|
|
|
|
x))
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;;;;; grid functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun gamegrid-get-cell (x y)
|
|
|
|
(char-after (gamegrid-cell-offset x y)))
|
|
|
|
|
|
|
|
(defun gamegrid-set-cell (x y c)
|
|
|
|
(save-excursion
|
|
|
|
(let ((buffer-read-only nil))
|
|
|
|
(goto-char (gamegrid-cell-offset x y))
|
|
|
|
(delete-char 1)
|
|
|
|
(insert-char c 1)
|
|
|
|
(gamegrid-set-face c))))
|
|
|
|
|
|
|
|
(defun gamegrid-init-buffer (width height blank)
|
|
|
|
(setq gamegrid-buffer-width width
|
|
|
|
gamegrid-buffer-height height)
|
|
|
|
(let ((line (concat
|
|
|
|
(make-string width blank)
|
|
|
|
"\n"))
|
|
|
|
(buffer-read-only nil))
|
|
|
|
(erase-buffer)
|
|
|
|
(setq gamegrid-buffer-start (point))
|
|
|
|
(dotimes (i height)
|
2001-11-26 16:16:45 +00:00
|
|
|
(insert line))
|
2002-09-23 16:03:03 +00:00
|
|
|
;; Adjust the height of the default face to the height of the
|
|
|
|
;; images. Unlike XEmacs, Emacs doesn't allow to make the default
|
|
|
|
;; face buffer-local; so we do this with an overlay.
|
|
|
|
(when (eq gamegrid-display-mode 'glyph)
|
|
|
|
(overlay-put (make-overlay (point-min) (point-max))
|
|
|
|
'face gamegrid-face))
|
1998-06-14 21:32:23 +00:00
|
|
|
(goto-char (point-min))))
|
|
|
|
|
|
|
|
(defun gamegrid-init (options)
|
|
|
|
(setq buffer-read-only t
|
|
|
|
truncate-lines t
|
2007-08-28 04:02:51 +00:00
|
|
|
line-spacing 0
|
1998-06-14 21:32:23 +00:00
|
|
|
gamegrid-display-options options)
|
|
|
|
(buffer-disable-undo (current-buffer))
|
|
|
|
(gamegrid-initialize-display))
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;;;;; timer functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun gamegrid-start-timer (period func)
|
|
|
|
(setq gamegrid-timer
|
2007-11-01 03:18:42 +00:00
|
|
|
(if (featurep 'xemacs)
|
1998-06-14 21:32:23 +00:00
|
|
|
(start-itimer "Gamegrid"
|
|
|
|
func
|
|
|
|
period
|
|
|
|
period
|
|
|
|
nil
|
|
|
|
t
|
|
|
|
(current-buffer))
|
|
|
|
(run-with-timer period
|
|
|
|
period
|
|
|
|
func
|
|
|
|
(current-buffer)))))
|
|
|
|
|
|
|
|
(defun gamegrid-set-timer (delay)
|
|
|
|
(if gamegrid-timer
|
2005-07-16 18:34:22 +00:00
|
|
|
(if (fboundp 'set-itimer-restart)
|
1998-06-14 21:32:23 +00:00
|
|
|
(set-itimer-restart gamegrid-timer delay)
|
|
|
|
(timer-set-time gamegrid-timer
|
|
|
|
(list (aref gamegrid-timer 1)
|
|
|
|
(aref gamegrid-timer 2)
|
|
|
|
(aref gamegrid-timer 3))
|
|
|
|
delay))))
|
|
|
|
|
|
|
|
(defun gamegrid-kill-timer ()
|
|
|
|
(if gamegrid-timer
|
2007-11-01 03:18:42 +00:00
|
|
|
(if (featurep 'xemacs)
|
1998-06-14 21:32:23 +00:00
|
|
|
(delete-itimer gamegrid-timer)
|
2007-01-28 19:40:31 +00:00
|
|
|
(cancel-timer gamegrid-timer)))
|
1998-06-14 21:32:23 +00:00
|
|
|
(setq gamegrid-timer nil))
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;;;; high score functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun gamegrid-add-score (file score)
|
2003-02-26 10:19:29 +00:00
|
|
|
"Add the current score to the high score file.
|
|
|
|
|
|
|
|
On POSIX systems there may be a shared game directory for all users in
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
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
|
2003-02-26 10:19:29 +00:00
|
|
|
`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
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
group. You probably need special user privileges to do this.
|
2003-02-26 10:19:29 +00:00
|
|
|
|
|
|
|
On non-POSIX systems Emacs searches for FILE in the directory
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
specified by the variable `temporary-file-directory'. If necessary,
|
2003-02-26 10:19:29 +00:00
|
|
|
FILE is created there."
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(pcase system-type
|
|
|
|
((or `ms-dos `windows-nt)
|
2002-04-13 20:26:36 +00:00
|
|
|
(gamegrid-add-score-insecure file score))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
(_
|
2002-04-13 20:26:36 +00:00
|
|
|
(gamegrid-add-score-with-update-game-score file score))))
|
|
|
|
|
2003-04-29 23:06:50 +00:00
|
|
|
|
|
|
|
;; On POSIX systems there are four cases to distinguish:
|
|
|
|
|
|
|
|
;; 1. FILE is an absolute filename. Then it should be a file in
|
|
|
|
;; temporary file directory. This is the way,
|
|
|
|
;; `gamegrid-add-score' was supposed to be used in the past and
|
|
|
|
;; is covered here for backward-compatibility.
|
|
|
|
;;
|
|
|
|
;; 2. The helper program "update-game-score" is setuid and the
|
|
|
|
;; file FILE does already exist in a system wide shared game
|
|
|
|
;; directory. This should be the normal case on POSIX systems,
|
|
|
|
;; if the game was installed system wide. Use
|
|
|
|
;; "update-game-score" to add the score to the file in the
|
|
|
|
;; shared game directory.
|
|
|
|
;;
|
|
|
|
;; 3. "update-game-score" is setuid, but the file FILE does *not*
|
|
|
|
;; exist in the system wide shared game directory. Use
|
|
|
|
;; `gamegrid-add-score-insecure' to create--if necessary--and
|
|
|
|
;; update FILE. This is for the case that a user has installed
|
|
|
|
;; a game on her own.
|
|
|
|
;;
|
|
|
|
;; 4. "update-game-score" is not setuid. Use it to create/update
|
|
|
|
;; FILE in the user's home directory. There is presumably no
|
|
|
|
;; shared game directory.
|
|
|
|
|
2005-07-16 18:34:22 +00:00
|
|
|
(defvar gamegrid-shared-game-dir)
|
|
|
|
|
2002-04-13 20:26:36 +00:00
|
|
|
(defun gamegrid-add-score-with-update-game-score (file score)
|
2011-04-21 12:24:46 +00:00
|
|
|
(let ((gamegrid-shared-game-dir
|
|
|
|
(not (zerop (logand (file-modes
|
|
|
|
(expand-file-name "update-game-score"
|
|
|
|
exec-directory))
|
|
|
|
#o4000)))))
|
2003-04-29 23:06:50 +00:00
|
|
|
(cond ((file-name-absolute-p file)
|
|
|
|
(gamegrid-add-score-insecure file score))
|
2005-07-16 18:34:22 +00:00
|
|
|
((and gamegrid-shared-game-dir
|
2003-04-29 23:06:50 +00:00
|
|
|
(file-exists-p (expand-file-name file shared-game-score-directory)))
|
|
|
|
;; Use the setuid "update-game-score" program to update a
|
|
|
|
;; system-wide score file.
|
2005-07-16 18:34:22 +00:00
|
|
|
(gamegrid-add-score-with-update-game-score-1 file
|
2003-04-29 23:06:50 +00:00
|
|
|
(expand-file-name file shared-game-score-directory) score))
|
|
|
|
;; Else: Add the score to a score file in the user's home
|
|
|
|
;; directory.
|
2005-07-16 18:34:22 +00:00
|
|
|
(gamegrid-shared-game-dir
|
|
|
|
;; If `gamegrid-shared-game-dir' is non-nil, then
|
2003-04-29 23:06:50 +00:00
|
|
|
;; "update-gamescore" program is setuid, so don't use it.
|
|
|
|
(unless (file-exists-p
|
|
|
|
(directory-file-name gamegrid-user-score-file-directory))
|
|
|
|
(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)))
|
2005-07-16 18:34:22 +00:00
|
|
|
(gamegrid-add-score-with-update-game-score-1 file f score))))))
|
2003-02-26 10:19:29 +00:00
|
|
|
|
2005-07-16 18:34:22 +00:00
|
|
|
(defun gamegrid-add-score-with-update-game-score-1 (file target score)
|
2003-02-26 10:19:29 +00:00
|
|
|
(let ((default-directory "/")
|
2007-03-03 12:18:56 +00:00
|
|
|
(errbuf (generate-new-buffer " *update-game-score loss*"))
|
|
|
|
(marker-string (concat
|
|
|
|
(user-full-name)
|
|
|
|
" <"
|
|
|
|
(cond ((fboundp 'user-mail-address)
|
|
|
|
(user-mail-address))
|
|
|
|
((boundp 'user-mail-address)
|
|
|
|
user-mail-address)
|
|
|
|
(t ""))
|
|
|
|
"> "
|
|
|
|
(current-time-string))))
|
2007-01-28 19:40:31 +00:00
|
|
|
;; This can be called from a timer, so enable local quits.
|
|
|
|
(with-local-quit
|
|
|
|
(apply
|
|
|
|
'call-process
|
|
|
|
(append
|
|
|
|
(list
|
|
|
|
(expand-file-name "update-game-score" exec-directory)
|
|
|
|
nil errbuf nil
|
|
|
|
"-m" (int-to-string gamegrid-score-file-length)
|
|
|
|
"-d" (if gamegrid-shared-game-dir
|
|
|
|
(expand-file-name shared-game-score-directory)
|
|
|
|
(file-name-directory target))
|
|
|
|
file
|
|
|
|
(int-to-string score)
|
2007-03-03 12:18:56 +00:00
|
|
|
marker-string))))
|
2002-04-10 23:16:45 +00:00
|
|
|
(if (buffer-modified-p errbuf)
|
|
|
|
(progn
|
|
|
|
(display-buffer errbuf)
|
|
|
|
(error "Failed to update game score file"))
|
|
|
|
(kill-buffer errbuf))
|
2007-01-28 19:40:31 +00:00
|
|
|
(let ((buf (find-buffer-visiting target)))
|
2007-03-03 12:18:56 +00:00
|
|
|
(save-excursion
|
|
|
|
(if buf
|
|
|
|
(progn
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
(revert-buffer nil t nil)
|
|
|
|
(display-buffer buf))
|
|
|
|
(find-file-read-only target))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(search-forward (concat (int-to-string score)
|
|
|
|
" " (user-login-name) " "
|
2012-11-17 07:00:35 +00:00
|
|
|
marker-string) nil t)
|
2007-03-03 12:18:56 +00:00
|
|
|
(beginning-of-line)))))
|
2002-04-23 20:24:40 +00:00
|
|
|
|
2003-02-26 10:19:29 +00:00
|
|
|
(defun gamegrid-add-score-insecure (file score &optional directory)
|
2002-04-13 20:26:36 +00:00
|
|
|
(save-excursion
|
2003-02-26 10:19:29 +00:00
|
|
|
(setq file (expand-file-name file (or directory
|
|
|
|
temporary-file-directory)))
|
2002-04-13 20:26:36 +00:00
|
|
|
(find-file-other-window file)
|
|
|
|
(setq buffer-read-only nil)
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert (format "%05d\t%s\t%s <%s>\n"
|
|
|
|
score
|
|
|
|
(current-time-string)
|
|
|
|
(user-full-name)
|
|
|
|
(cond ((fboundp 'user-mail-address)
|
|
|
|
(user-mail-address))
|
|
|
|
((boundp 'user-mail-address)
|
|
|
|
user-mail-address)
|
|
|
|
(t ""))))
|
2004-04-05 11:57:14 +00:00
|
|
|
(sort-fields 1 (point-min) (point-max))
|
2002-04-13 20:26:36 +00:00
|
|
|
(reverse-region (point-min) (point-max))
|
2009-08-22 19:29:18 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line gamegrid-score-file-length)
|
2002-04-13 20:26:36 +00:00
|
|
|
(delete-region (point) (point-max))
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
(save-buffer)))
|
|
|
|
|
1998-06-14 21:32:23 +00:00
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(provide 'gamegrid)
|
2001-07-16 09:10:19 +00:00
|
|
|
|
|
|
|
;;; gamegrid.el ends here
|