APPROVE COMMIT
NOTE: This patch has been committed.
xemacs-packages/games/ChangeLog addition:
2011-03-17 Aidan Kehoe <kehoea(a)parhasard.net>
* sudoku.el:
* sudoku.el (sudoku-mode-setup-modeline):
* sudoku.el (sudoku-autoinsert):
* sudoku.el (sudoku-pencil-mode):
* sudoku.el (sudoku-download-puzzle):
* sudoku.el (sudoku-print):
* sudoku.el (sudoku-sdk-file-p):
* sudoku.el (sudoku-string-to-board):
* sudoku.el (sudoku-builtin-puzzles): Moved.
Update this file to work better with more recent versions of XEmacs.
This involves:
-- modeline-multibyte-status -> modeline-coding-system
-- Using unquoted symbols in `block' and `return-from', as always
documented but only recently forced.
-- Use #'signum, not #'positivep (the latter is not in any
standard and was never built-in to XEmacs.
-- Mark various special symbols used by the code as such.
XEmacs Packages source patch:
Diff command: cvs -q diff -Nu
Files affected: xemacs-packages/games/sudoku.el
Index: xemacs-packages/games/sudoku.el
===================================================================
RCS file: /cvsroot/xemacs/XEmacs/packages/xemacs-packages/games/sudoku.el,v
retrieving revision 1.1
diff -u -u -r1.1 sudoku.el
--- xemacs-packages/games/sudoku.el 12 Apr 2010 08:20:24 -0000 1.1
+++ xemacs-packages/games/sudoku.el 17 Mar 2011 19:13:47 -0000
@@ -138,11 +138,6 @@
(require 'cl)
(require 'easymenu)
-;; XEmacs compatibility
-(unless (fboundp 'positivep)
- (defun positivep (num)
- (and (numberp num) (> num 0))))
-
;;{{{ Custom variables
(defgroup sudoku nil
@@ -540,7 +535,7 @@
(setq modeline-format
(list
""
- modeline-multibyte-status
+ modeline-coding-system
"--"
(cons modeline-buffer-id-extent 'modeline-buffer-identification)
" "
@@ -1012,16 +1007,16 @@
was incorrect.
Auto-insert does not work for pencils."
(interactive)
- (unless (or (positivep sudoku-current-pencil)
+ (unless (or (eql 1 (signum sudoku-current-pencil))
(and cell (sudoku-cell-empty-p cell)))
(let ((gc (or cell (sudoku-current-cell)))
(sb (copy-tree sudoku-current-board)))
(unwind-protect
- (block 'autoins
+ (block autoins
(while (some #'(lambda (fun)
(let ((rv (funcall fun cell deduce)))
(when (and deduce rv)
- (return-from 'autoins t))
+ (return-from autoins t))
rv))
sudoku-deduce-methods)))
;; Save previous board to stack, for undo
@@ -1399,7 +1394,7 @@
If `sudoku-current-pencil' is 2, then reset to pen."
(interactive "P")
(cond (arg
- (when (positivep sudoku-current-pencil)
+ (when (eql 1 (signum sudoku-current-pencil))
(let* ((cp sudoku-current-pencil)
(sudoku-current-pencil (1- cp)))
(sudoku-pencil-reset cp))
@@ -1568,6 +1563,7 @@
(sud (with-temp-buffer
(if (fboundp 'url-retrieve)
(let ((url-working-buffer (current-buffer)))
+ (declare (special url-working-buffer))
(url-retrieve source))
(call-process "curl" nil t nil "-s" source))
(goto-char (point-min))
@@ -1635,6 +1631,7 @@
"Print current puzzle."
(interactive)
(let ((auto-insert nil))
+ (declare (special auto-insert))
(find-file (format "/tmp/sudoku-%s.tex"
(sudoku-puzzle-id sudoku-puzzle))))
(erase-buffer)
@@ -1717,7 +1714,7 @@
"Return non-nil if FILE can be readed by `sudoku-load-puzzle'.
Can be used with `find-file-magic-files-alist'."
(ignore-errors
- (block 'sdk-file
+ (block sdk-file
(with-temp-buffer
(insert-file-contents-literally file)
(goto-char (point-min))
@@ -1727,17 +1724,17 @@
(forward-line))
(dotimes (i 9)
(unless (looking-at "^[123456789.]\\{9,9\\}\r?$")
- (return-from 'sdk-file nil))
+ (return-from sdk-file nil))
(forward-line))
;; State
(unless (eobp)
(unless (looking-at "\\[State\\]\r?$")
- (return-from 'sdk-file nil))
+ (return-from sdk-file nil))
(forward-line)
(dotimes (i 9)
(unless (looking-at "^[123456789.]\\{9,9\\}\r?$")
- (return-from 'sdk-file nil))
+ (return-from sdk-file nil))
(forward-line)))
t))))
@@ -1786,12 +1783,6 @@
;;{{{ Built-in puzzles
-(defun sudoku-builtin-puzzles (level)
- "Filter builtin puzzles by LEVEL."
- (remove-if-not #'(lambda (bip)
- (eq (plist-get (cdr bip) :level) level))
- sudoku-builtin-puzzles))
-
(defun sudoku-string-to-board (nl)
"Convert flat numbers list NL to sudoku board."
(setq nl (mapcar #'(lambda (c) (- (char-to-int c) 48))
@@ -1993,6 +1984,11 @@
("170050000800200000045000600000500430010070000006090002000006000200000040000300180"
:level evil :url "http://lgarc.narod.ru/xemacs/sudoku.el")
))
+(defun sudoku-builtin-puzzles (level)
+ "Filter builtin puzzles by LEVEL."
+ (remove-if-not #'(lambda (bip) (eq (plist-get (cdr bip) :level) level))
+ sudoku-builtin-puzzles))
+
;;}}}
(provide 'sudoku) nil
--
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
-- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches