Commits

Anonymous committed 4764c34

Update sudoku to work with more recent versions of the byte compiler

Comments (0)

Files changed (2)

+2011-03-17  Aidan Kehoe  <kehoea@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.
+
 2010-04-28  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.20 released.
 (require 'cl)
 (require 'easymenu)
 
-;; XEmacs compatibility
-(unless (fboundp 'positivep)
-  (defun positivep (num)
-    (and (numberp num) (> num 0))))
-
 ;;{{{ Custom variables
 
 (defgroup sudoku nil
   (setq modeline-format
         (list
          ""
-         modeline-multibyte-status
+         modeline-coding-system
          "--"
          (cons modeline-buffer-id-extent 'modeline-buffer-identification)
          " "
 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
 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))
          (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))
   "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)
   "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))
           (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))))
 
 
 ;;{{{ 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))
     ("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