X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/c07bb40b73856e3c40daf1dc6007ea13e3870912..528b9ea9fff19090ae08197fd4b7ccd9b26caa47:/lisp/play/mpuz.el diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el index 5cb2ed0c9c..954730c949 100644 --- a/lisp/play/mpuz.el +++ b/lisp/play/mpuz.el @@ -1,7 +1,7 @@ ;;; mpuz.el --- multiplication puzzle for GNU Emacs -;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005, -;; 2006, 2007 Free Software Foundation, Inc. +;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, +;; 2009, 2010 Free Software Foundation, Inc. ;; Author: Philippe Schnoebelen ;; Overhauled: Daniel Pfeiffer @@ -9,10 +9,10 @@ ;; 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 2, 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 @@ -20,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 . ;;; Commentary: @@ -41,7 +39,7 @@ (random t) ; randomize (defcustom mpuz-silent 'error - "*Set this to nil if you want dings on inputs. + "Set this to nil if you want dings on inputs. t means never ding, and `error' means only ding on wrong input." :type '(choice (const :tag "No" nil) (const :tag "Yes" t) @@ -49,36 +47,36 @@ t means never ding, and `error' means only ding on wrong input." :group 'mpuz) (defcustom mpuz-solve-when-trivial t - "*Solve any row that can be trivially calculated from what you've found." + "Solve any row that can be trivially calculated from what you've found." :type 'boolean :group 'mpuz) (defcustom mpuz-allow-double-multiplicator nil - "*Allow 2nd factors like 33 or 77." + "Allow 2nd factors like 33 or 77." :type 'boolean :group 'mpuz) (defface mpuz-unsolved '((((class color)) (:foreground "red1" :bold t)) (t (:bold t))) - "*Face to use for letters to be solved." + "Face to use for letters to be solved." :group 'mpuz) (defface mpuz-solved '((((class color)) (:foreground "green1" :bold t)) (t (:bold t))) - "*Face to use for solved digits." + "Face to use for solved digits." :group 'mpuz) (defface mpuz-trivial '((((class color)) (:foreground "blue" :bold t)) (t (:bold t))) - "*Face to use for trivial digits solved for you." + "Face to use for trivial digits solved for you." :group 'mpuz) (defface mpuz-text '((t (:inherit variable-pitch))) - "*Face to use for text on right." + "Face to use for text on right." :group 'mpuz) @@ -300,8 +298,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." (let ((buf (get-buffer-create "*Mult Puzzle*")) (face '(face mpuz-text)) buffer-read-only) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (erase-buffer) (insert mpuz-framework) (set-text-properties 13 42 face) @@ -322,12 +319,14 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." (defun mpuz-paint-errors () "Paint error count on the puzzle screen." (mpuz-switch-to-window) - (goto-line 3) + (goto-char (point-min)) + (forward-line 2) (mpuz-paint-number (prin1-to-string mpuz-nb-errors))) (defun mpuz-paint-statistics () "Paint statistics about previous games on the puzzle screen." - (goto-line 7) + (goto-char (point-min)) + (forward-line 6) (mpuz-paint-number (prin1-to-string mpuz-nb-completed-games)) (mpuz-paint-number (format "%.2f" @@ -354,7 +353,8 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." ('mpuz-unsolved)))) buffer-read-only) (mapc (lambda (square) - (goto-line (car square)) ; line before column! + (goto-char (point-min)) + (forward-line (1- (car square))) ; line before column! (move-to-column (cdr square)) (insert char) (set-text-properties (1- (point)) (point) face) @@ -426,7 +426,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." (interactive) (if mpuz-in-progress (let (letter-char digit digit-char message) - (setq letter-char (upcase last-command-char) + (setq letter-char (upcase last-command-event) digit (mpuz-to-digit (- letter-char ?A))) (cond ((mpuz-digit-solved-p digit) (message "%c already solved." letter-char) @@ -489,7 +489,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." ((< mpuz-nb-errors 10) "bad!") ((< mpuz-nb-errors 15) "awful.") (t "not serious."))))) - (message message) + (message "%s" message) (sit-for 4) (if (y-or-n-p (concat message " Start a new game? ")) (mpuz-start-new-game) @@ -518,5 +518,5 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." (provide 'mpuz) -;;; arch-tag: 2781d6ba-89e7-43b5-85c7-5d3a2e73feb1 +;; arch-tag: 2781d6ba-89e7-43b5-85c7-5d3a2e73feb1 ;;; mpuz.el ends here