;;; mpuz.el --- multiplication puzzle for GNU Emacs
-;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;; 2009, 2010 Free Software Foundation, Inc.
;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
;; Overhauled: Daniel Pfeiffer <occitan@esperanto.org>
;; 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
;; 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:
(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)
: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)
\f
(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)
(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"
('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)
(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)