+2011-04-21 Juanma Barranquero <lekktu@gmail.com>
+
+ Lexical-binding cleanup.
+
+ * play/5x5.el (5x5-make-random-solution, 5x5-make-mutate-current)
+ (5x5-make-mutate-best):
+ * play/fortune.el (fortune-in-buffer):
+ * play/gomoku.el (gomoku-init-display):
+ * play/solitaire.el (solitaire, solitaire-do-check):
+ * play/tetris.el (tetris-default-update-speed-function):
+ Mark unused parameters.
+
+ * play/bubbles.el (bubbles-mode): Set `show-trailing-whitespace'.
+ (bubbles--shift): Remove unused variable `char-org'.
+ (bubbles--set-faces): Remove unused variable `fg-col'. Simplify.
+ (bubbles--show-images): Remove unused variable `char'.
+
+ * play/decipher.el (decipher-keypress, decipher-alphabet-keypress)
+ (decipher-get-undo, decipher-set-map, decipher-complete-alphabet)
+ (decipher-resync, decipher-loop-with-breaks, decipher--analyze)
+ (decipher-analyze-buffer): Use ?\s.
+ (decipher-make-checkpoint): Remove unused variable `mapping'.
+
+ * play/doctor.el (doctor-doc): Rename parameter DOCTOR-SENT to SENT.
+
+ * play/gamegrid.el (gamegrid-add-score-with-update-game-score):
+ Remove unused variable `result'; use `let'.
+
+ * play/gametree.el (gametree-current-layout, gametree-apply-layout):
+ Rename parameter TOP-LEVEL to FROM-TOP-LEVEL; use `ignore-errors'.
+ (gametree-children-shown-p, gametree-compute-reduced-score):
+ Use `ignore-errors'.
+
+ * play/handwrite.el (ps-lpr-switches): Declare.
+ (handwrite): Remove unused variables `pmin' and `lastp'.
+
+ * play/hanoi.el (hanoi-move-ring): Remove unused variable `total-steps'.
+
+ * play/landmark.el (landmark-init-display)
+ (landmark-update-naught-weights): Mark unused parameters.
+ (landmark-y): Remove unused variable `noise'. Simplify.
+ (landmark-human-plays): Remove unused variable `score'.
+
+ * play/mpuz.el (mpuz-try-letter): Remove unused variable `message'.
+ (mpuz-try-proposal): Remove unused variable `game'.
+
+ * play/zone.el (life-patterns): Declare.
+
2011-04-20 Juanma Barranquero <lekktu@gmail.com>
* vc/vc.el (ediff-vc-internal): Declare function.
(5x5-copy-grid best-solution)))))
(setq 5x5-cracking nil))
-(defun 5x5-make-random-solution (&rest ignore)
+(defun 5x5-make-random-solution (&rest _ignore)
"Make a random solution."
(5x5-make-random-grid))
-(defun 5x5-make-mutate-current (current best)
+(defun 5x5-make-mutate-current (current _best)
"Mutate the current solution."
(5x5-mutate-solution current))
-(defun 5x5-make-mutate-best (current best)
+(defun 5x5-make-mutate-best (_current best)
"Mutate the best solution."
(5x5-mutate-solution best))
-;;; bubbles.el --- Puzzle game for Emacs.
+;;; bubbles.el --- Puzzle game for Emacs
;; Copyright (C) 2007-2011 Free Software Foundation, Inc.
(define-derived-mode bubbles-mode nil "Bubbles"
"Major mode for playing bubbles.
\\{bubbles-mode-map}"
- (setq buffer-read-only t)
+ (setq buffer-read-only t
+ show-trailing-whitespace nil)
(buffer-disable-undo)
(force-mode-line-update)
(redisplay)
Return t if new char is non-empty."
(save-excursion
(when (bubbles--goto row col)
- (let ((char-org (char-after (point)))
- (char-new (bubbles--empty-char))
+ (let ((char-new (bubbles--empty-char))
(removed nil)
(trow row)
(tcol col)
(dotimes (i (bubbles--grid-height))
(dotimes (j (bubbles--grid-width))
(bubbles--goto i j)
- (let* ((index (get-text-property (point) 'index))
- (face (nth index bubbles--faces))
- (fg-col (face-foreground face)))
+ (let ((face (nth (get-text-property (point) 'index)
+ bubbles--faces)))
(when (get-text-property (point) 'active)
(set-face-foreground 'bubbles--highlight-face "#ff0000")
(setq face 'bubbles--highlight-face))
(save-excursion
(goto-char (point-min))
(forward-line 1)
- (let ((inhibit-read-only t)
- char)
+ (let ((inhibit-read-only t))
(dotimes (i (bubbles--grid-height))
(dotimes (j (bubbles--grid-width))
(forward-char 1)
(let ((char-a (following-char))
(char-b (decipher-last-command-char)))
(or (and (not (= ?w (char-syntax char-a)))
- (= char-b ?\ )) ;Spacebar just advances on non-letters
+ (= char-b ?\s)) ;Spacebar just advances on non-letters
(funcall decipher-function char-a char-b)))))
(forward-char))
(decipher-set-map a b))
((and (>= a ?a) (<= a ?z))
;; If A is lowercase, then it is in the plaintext alphabet:
- (if (= b ?\ )
+ (if (= b ?\s)
;; We are clearing the association (if any):
- (if (/= ?\ (setq b (cdr (assoc a decipher-alphabet))))
- (decipher-set-map b ?\ ))
+ (if (/= ?\s (setq b (cdr (assoc a decipher-alphabet))))
+ (decipher-set-map b ?\s))
;; Associate the plaintext char with the char pressed:
(decipher-set-map b a)))
(t
;; modified using setcdr.
(let ((cipher-map (decipher-copy-cons (rassoc cipher-char decipher-alphabet)))
(plain-map (decipher-copy-cons (assoc plain-char decipher-alphabet))))
- (cond ((equal ?\ plain-char)
+ (cond ((equal ?\s plain-char)
cipher-map)
((equal cipher-char (cdr plain-map))
nil) ;We aren't changing anything
- ((equal ?\ (cdr plain-map))
- (or cipher-map (cons ?\ cipher-char)))
+ ((equal ?\s (cdr plain-map))
+ (or cipher-map (cons ?\s cipher-char)))
(cipher-map
(list plain-map cipher-map))
(t
(goto-char (point-min))
(if (setq mapping (rassoc cipher-char decipher-alphabet))
(progn
- (setcdr mapping ?\ )
+ (setcdr mapping ?\s)
(search-forward-regexp (concat "^([a-z]*"
(char-to-string (car mapping))))
- (decipher-insert ?\ )
+ (decipher-insert ?\s)
(beginning-of-line)))
(if (setq mapping (assoc plain-char decipher-alphabet))
(progn
- (if (/= ?\ (cdr mapping))
- (decipher-set-map (cdr mapping) ?\ t))
+ (if (/= ?\s (cdr mapping))
+ (decipher-set-map (cdr mapping) ?\s t))
(setcdr mapping cipher-char)
(search-forward-regexp (concat "^([a-z]*" plain-string))
(decipher-insert cipher-char)
(or (stringp desc)
(setq desc ""))
(let (alphabet
- buffer-read-only ;Make buffer writable
- mapping)
+ buffer-read-only) ;Make buffer writable
(goto-char (point-min))
(re-search-forward "^)")
(move-to-column 27 t)
buffer-read-only ;Make buffer writable
plain-map undo-rec)
(while (setq plain-map (pop ptr))
- (if (equal ?\ (cdr plain-map))
+ (if (equal ?\s (cdr plain-map))
(progn
(while (rassoc cipher-char decipher-alphabet)
;; Find the next unused letter
(incf cipher-char))
- (push (cons ?\ cipher-char) undo-rec)
+ (push (cons ?\s cipher-char) undo-rec)
(decipher-set-map cipher-char (car plain-map) t))))
(decipher-add-undo undo-rec)))
(replace-match ">" nil nil))
(decipher-read-alphabet)
(while (setq mapping (pop alphabet))
- (or (equal ?\ (cdr mapping))
+ (or (equal ?\s (cdr mapping))
(decipher-set-map (cdr mapping) (car mapping))))))
(setq decipher-undo-list nil
decipher-undo-list-size 0)
a space.
See `decipher-loop-no-breaks' if you do not care about word divisions."
- (let ((decipher-char ?\ )
- (decipher--loop-prev-char ?\ ))
+ (let ((decipher-char ?\s)
+ (decipher--loop-prev-char ?\s))
(save-excursion
(goto-char (point-min))
(funcall func) ;Space marks beginning of first word
(while (not (eolp))
(setq decipher-char (upcase (following-char)))
(or (and (>= decipher-char ?A) (<= decipher-char ?Z))
- (setq decipher-char ?\ ))
- (or (and (equal decipher-char ?\ )
- (equal decipher--loop-prev-char ?\ ))
+ (setq decipher-char ?\s))
+ (or (and (equal decipher-char ?\s)
+ (equal decipher--loop-prev-char ?\s))
(funcall func))
(setq decipher--loop-prev-char decipher-char)
(forward-char))
- (or (equal decipher-char ?\ )
+ (or (equal decipher-char ?\s)
(progn
(setq decipher-char ?\s
- decipher--loop-prev-char ?\ )
+ decipher--loop-prev-char ?\s)
(funcall func)))))))
(defun decipher-loop-no-breaks (func)
decipher--digram-list)))))
(and (>= decipher--prev-char ?A)
(incf (aref (aref decipher--before (- decipher--prev-char ?A))
- (if (equal decipher-char ?\ )
+ (if (equal decipher-char ?\s)
26
(- decipher-char ?A)))))
(and (>= decipher-char ?A)
(incf (aref decipher--freqs (- decipher-char ?A)))
(incf (aref (aref decipher--after (- decipher-char ?A))
- (if (equal decipher--prev-char ?\ )
+ (if (equal decipher--prev-char ?\s)
26
(- decipher--prev-char ?A)))))
(setq decipher--prev-char decipher-char))
(defun decipher-analyze-buffer ()
"Perform frequency analysis and store results in statistics buffer.
Creates the statistics buffer if it doesn't exist."
- (let ((decipher--prev-char (if decipher-ignore-spaces ?\ ?\*))
+ (let ((decipher--prev-char (if decipher-ignore-spaces ?\s ?\*))
(decipher--before (make-vector 26 nil))
(decipher--after (make-vector 26 nil))
(decipher--freqs (make-vector 26 0))
;; (setq undo-rec (list undo-rec)))
;; (insert ?\()
;; (while (setq undo-map (pop undo-rec))
-;; (insert (cdr undo-map) (car undo-map) ?\ ))
+;; (insert (cdr undo-map) (car undo-map) ?\s))
;; (delete-char -1)
;; (insert ")\n"))))))
(you seem to dwell on (doc// doctor-owner) family \.)
((doc$ doctor--areyou) hung up on (doc// doctor-owner) family \?)))
(set (make-local-variable 'doctor--huhlst)
- '(((doc$ doctor--whysay)(doc// doctor-sent) \?)
+ '(((doc$ doctor--whysay) (doc// doctor-sent) \?)
(is it because of (doc$ doctor--things) that you say (doc// doctor-sent) \?)))
(set (make-local-variable 'doctor--longhuhlst)
'(((doc$ doctor--whysay) that \?)
(did you watch a lot of crime and violence on television as a child \?)))
(set (make-local-variable 'doctor--sexlst)
'(((doc$ doctor--areyou) (doc$ doctor--afraidof) sex \?)
- ((doc$ doctor--describe)(doc$ doctor--something) about your sexual history \.)
- ((doc$ doctor--please)(doc$ doctor--describe) your sex life \.\.\.)
+ ((doc$ doctor--describe) (doc$ doctor--something) about your sexual history \.)
+ ((doc$ doctor--please) (doc$ doctor--describe) your sex life \.\.\.)
((doc$ doctor--describe) your (doc$ doctor--feelings-about) your sexual partner \.)
((doc$ doctor--describe) your most (doc$ doctor--random-adjective) sexual experience \.)
((doc$ doctor--areyou) satisfied with (doc// doctor--lover) \.\.\. \?)))
((doc$ doctor--bother) i ask that \?)))
(set (make-local-variable 'doctor--beclst)
'((is it because (doc// doctor-sent) that you came to me \?)
- ((doc$ doctor--bother)(doc// doctor-sent) \?)
+ ((doc$ doctor--bother) (doc// doctor-sent) \?)
(when did you first know that (doc// doctor-sent) \?)
(is the fact that (doc// doctor-sent) the real reason \?)
(does the fact that (doc// doctor-sent) explain anything else \?)
- ((doc$ doctor--areyou)(doc$ doctor--sure)(doc// doctor-sent) \? )))
+ ((doc$ doctor--areyou) (doc$ doctor--sure) (doc// doctor-sent) \? )))
(set (make-local-variable 'doctor--shortbeclst)
'(((doc$ doctor--bother) i ask you that \?)
(that\'s not much of an answer!)
(don\'t be (doc$ doctor--afraidof) elaborating \.)
((doc$ doctor--please) go into more detail \.)))
(set (make-local-variable 'doctor--thlst)
- '(((doc$ doctor--maybe)(doc$ doctor--thing)(doc$ doctor--isrelated) this \.)
- ((doc$ doctor--maybe)(doc$ doctor--things)(doc$ doctor--arerelated) this \.)
+ '(((doc$ doctor--maybe) (doc$ doctor--thing) (doc$ doctor--isrelated) this \.)
+ ((doc$ doctor--maybe) (doc$ doctor--things) (doc$ doctor--arerelated) this \.)
(is it because of (doc$ doctor--things) that you are going through all this \?)
(how do you reconcile (doc$ doctor--things) \? )
- ((doc$ doctor--maybe) this (doc$ doctor--isrelated)(doc$ doctor--things) \?)))
+ ((doc$ doctor--maybe) this (doc$ doctor--isrelated) (doc$ doctor--things) \?)))
(set (make-local-variable 'doctor--remlst)
'((earlier you said (doc$ doctor--history) \?)
(you mentioned that (doc$ doctor--history) \?)
- ((doc$ doctor--whysay)(doc$ doctor--history) \? )))
+ ((doc$ doctor--whysay) (doc$ doctor--history) \? )))
(set (make-local-variable 'doctor--toklst)
'((is this how you relax \?)
(how long have you been smoking grass \?)
'((do you get (doc// doctor-found) often \?)
(do you enjoy being (doc// doctor-found) \?)
(what makes you (doc// doctor-found) \?)
- (how often (doc$ doctor--areyou)(doc// doctor-found) \?)
+ (how often (doc$ doctor--areyou) (doc// doctor-found) \?)
(when were you last (doc// doctor-found) \?)))
(set (make-local-variable 'doctor--replist) '((i . (you))
(my . (your))
\f
;; Main processing function for sentences that have been read.
-(defun doctor-doc (doctor-sent)
+(defun doctor-doc (sent)
(cond
- ((equal doctor-sent '(foo))
- (doctor-type '(bar! (doc$ doctor--please)(doc$ doctor--continue) \.)))
- ((member doctor-sent doctor--howareyoulst)
+ ((equal sent '(foo))
+ (doctor-type '(bar! (doc$ doctor--please) (doc$ doctor--continue) \.)))
+ ((member sent doctor--howareyoulst)
(doctor-type '(i\'m ok \. (doc$ doctor--describe) yourself \.)))
- ((or (member doctor-sent '((good bye) (see you later) (i quit) (so long)
+ ((or (member sent '((good bye) (see you later) (i quit) (so long)
(go away) (get lost)))
- (memq (car doctor-sent)
+ (memq (car sent)
'(bye halt break quit done exit goodbye
bye\, stop pause goodbye\, stop pause)))
(doctor-type (doc$ doctor--bye)))
- ((and (eq (car doctor-sent) 'you)
- (memq (cadr doctor-sent) doctor--abusewords))
- (setq doctor-found (cadr doctor-sent))
+ ((and (eq (car sent) 'you)
+ (memq (cadr sent) doctor--abusewords))
+ (setq doctor-found (cadr sent))
(doctor-type (doc$ doctor--abuselst)))
- ((eq (car doctor-sent) 'whatmeans)
- (doctor-def (cadr doctor-sent)))
- ((equal doctor-sent '(parse))
+ ((eq (car sent) 'whatmeans)
+ (doctor-def (cadr sent)))
+ ((equal sent '(parse))
(doctor-type (list 'subj '= doctor-subj ", "
'verb '= doctor-verb "\n"
'object 'phrase '= doctor-obj ","
'sentence 'used 'was
"..."
'(doc// doctor--bak))))
- ((memq (car doctor-sent) '(are is do has have how when where who why))
+ ((memq (car sent) '(are is do has have how when where who why))
(doctor-type (doc$ doctor--qlist)))
- ;; ((eq (car doctor-sent) 'forget)
- ;; (set (cadr doctor-sent) nil)
- ;; (doctor-type '((doc$ doctor--isee)(doc$ doctor--please)
+ ;; ((eq (car sent) 'forget)
+ ;; (set (cadr sent) nil)
+ ;; (doctor-type '((doc$ doctor--isee) (doc$ doctor--please)
;; (doc$ doctor--continue)\.)))
(t
- (if (doctor-defq doctor-sent) (doctor-define doctor-sent doctor-found))
- (if (> (length doctor-sent) 12)(setq doctor-sent (doctor-shorten doctor-sent)))
- (setq doctor-sent (doctor-correct-spelling (doctor-replace doctor-sent doctor--replist)))
- (cond ((and (not (memq 'me doctor-sent))(not (memq 'i doctor-sent))
- (memq 'am doctor-sent))
- (setq doctor-sent (doctor-replace doctor-sent '((am . (are)))))))
- (cond ((equal (car doctor-sent) 'yow) (doctor-zippy))
- ((< (length doctor-sent) 2)
- (cond ((eq (doctor-meaning (car doctor-sent)) 'howdy)
+ (if (doctor-defq sent) (doctor-define sent doctor-found))
+ (if (> (length sent) 12) (setq sent (doctor-shorten sent)))
+ (setq sent (doctor-correct-spelling (doctor-replace sent doctor--replist)))
+ (cond ((and (not (memq 'me sent)) (not (memq 'i sent))
+ (memq 'am sent))
+ (setq sent (doctor-replace sent '((am . (are)))))))
+ (cond ((equal (car sent) 'yow) (doctor-zippy))
+ ((< (length sent) 2)
+ (cond ((eq (doctor-meaning (car sent)) 'howdy)
(doctor-howdy))
(t (doctor-short))))
(t
- (if (memq 'am doctor-sent)
- (setq doctor-sent (doctor-replace doctor-sent '((me . (i))))))
- (setq doctor-sent (doctor-fixup doctor-sent))
- (if (and (eq (car doctor-sent) 'do) (eq (cadr doctor-sent) 'not))
+ (if (memq 'am sent)
+ (setq sent (doctor-replace sent '((me . (i))))))
+ (setq sent (doctor-fixup sent))
+ (if (and (eq (car sent) 'do) (eq (cadr sent) 'not))
(cond ((zerop (random 3))
(doctor-type '(are you (doc$ doctor--afraidof) that \?)))
((zerop (random 2))
(doctor-rthing))
(t
(doctor-type '((doc$ doctor--whysay) that i shouldn\'t
- (cddr doctor-sent)
+ (cddr sent)
\?))))
- (doctor-go (doctor-wherego doctor-sent))))))))
+ (doctor-go (doctor-wherego sent))))))))
\f
;; Things done to process sentences once read.
(t 'something))))
(defun doctor-getnoun (x)
- (cond ((null x)(setq doctor-object 'something))
- ((atom x)(setq doctor-object x))
+ (cond ((null x) (setq doctor-object 'something))
+ ((atom x) (setq doctor-object x))
((eq (length x) 1)
(setq doctor-object (cond
((doctor-nounp (setq doctor-object (car x))) doctor-object)
sent)))
(defun doctor-wherego (sent)
- (cond ((null sent)(doc$ doctor--whereoutp))
+ (cond ((null sent) (doc$ doctor--whereoutp))
((null (doctor-meaning (car sent)))
(doctor-wherego (cond ((zerop (random 2))
(reverse (cdr sent)))
(setq foo (cdr foo)))
(setq doctor-verb (car foo))
(setq doctor-obj (doctor-getnoun (cdr foo)))
- (cond ((eq doctor-object 'i)(setq doctor-object 'me))
- ((eq doctor-subj 'me)(setq doctor-subj 'i)))
+ (cond ((eq doctor-object 'i) (setq doctor-object 'me))
+ ((eq doctor-subj 'me) (setq doctor-subj 'i)))
(cond (mem (doctor-remember (list doctor-subj doctor-verb doctor-obj))))))
(defun doctor-possess (sent key)
(defun doctor-rthing () (doctor-type (doc$ doctor--thlst)))
-(defun doctor-remem () (cond ((null doctor--history)(doctor-huh))
+(defun doctor-remem () (cond ((null doctor--history) (doctor-huh))
((doctor-type (doc$ doctor--remlst)))))
(defun doctor-howdy ()
(doctor-type '((doc$ doctor--please) (doc$ doctor--describe) (doc$ doctor--things) \.)))))
(defun doctor-when ()
- (cond ((< (length (memq doctor-found doctor-sent)) 3)(doctor-short))
+ (cond ((< (length (memq doctor-found doctor-sent)) 3) (doctor-short))
(t
(setq doctor-sent (cdr (memq doctor-found doctor-sent)))
(setq doctor-sent (doctor-fixup doctor-sent))
- (doctor-type '((doc$ doctor--whatwhen)(doc// doctor-sent) \?)))))
+ (doctor-type '((doc$ doctor--whatwhen) (doc// doctor-sent) \?)))))
(defun doctor-conj ()
- (cond ((< (length (memq doctor-found doctor-sent)) 4)(doctor-short))
+ (cond ((< (length (memq doctor-found doctor-sent)) 4) (doctor-short))
(t
(setq doctor-sent (cdr (memq doctor-found doctor-sent)))
(setq doctor-sent (doctor-fixup doctor-sent))
(doctor-type (doc$ doctor--toklst)))
(defun doctor-state ()
- (doctor-type (doc$ doctor--states))(doctor-remember (list 'you 'were doctor-found)))
+ (doctor-type (doc$ doctor--states)) (doctor-remember (list 'you 'were doctor-found)))
(defun doctor-mood ()
- (doctor-type (doc$ doctor--moods))(doctor-remember (list 'you 'felt doctor-found)))
+ (doctor-type (doc$ doctor--moods)) (doctor-remember (list 'you 'felt doctor-found)))
(defun doctor-fear ()
(setq doctor--feared (doctor-setprep doctor-sent doctor-found))
(doctor-svo doctor-sent doctor-found 1 t)
(cond ((memq 'not doctor-sent) (doctor-forget) (doctor-huh))
((equal doctor-subj 'you)
- (doctor-type '(why do you (doc// doctor-verb)(doc// doctor-obj) \?)))
- (t (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj))))))
+ (doctor-type '(why do you (doc// doctor-verb) (doc// doctor-obj) \?)))
+ (t (doctor-type '((doc$ doctor--whysay) (list doctor-subj doctor-verb doctor-obj))))))
(defun doctor-symptoms ()
(doctor-type '((doc$ doctor--maybe) you should consult a medical doctor\;
(doctor-hates1))
(defun doctor-hates1 ()
- (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj) \?)))
+ (doctor-type '((doc$ doctor--whysay) (list doctor-subj doctor-verb doctor-obj) \?)))
(defun doctor-loves ()
(doctor-svo doctor-sent doctor-found 1 t)
(doctor-qloves))
(defun doctor-qloves ()
- (doctor-type '((doc$ doctor--bother)(list doctor-subj doctor-verb doctor-obj) \?)))
+ (doctor-type '((doc$ doctor--bother) (list doctor-subj doctor-verb doctor-obj) \?)))
(defun doctor-love ()
(doctor-svo doctor-sent doctor-found 1 t)
(defun doctor-sexnoun () (doctor-sexverb))
(defun doctor-sexverb ()
- (if (or (memq 'me doctor-sent)(memq 'myself doctor-sent)(memq 'i doctor-sent))
+ (if (or (memq 'me doctor-sent) (memq 'myself doctor-sent) (memq 'i doctor-sent))
(doctor-foul)
(doctor-type (doc$ doctor--sexlst))))
;;; **************
;;; Display fortune
-(defun fortune-in-buffer (interactive &optional file)
+(defun fortune-in-buffer (_interactive &optional file)
"Put a fortune cookie in the *fortune* buffer.
INTERACTIVE is ignored. Optional argument FILE, when supplied,
specifies the file to choose the fortune from."
(defvar gamegrid-shared-game-dir)
(defun gamegrid-add-score-with-update-game-score (file score)
- (let* ((result nil) ;; What is this good for? -- os
- (gamegrid-shared-game-dir
- (not (zerop (logand (file-modes
- (expand-file-name "update-game-score"
- exec-directory))
- #o4000)))))
+ (let ((gamegrid-shared-game-dir
+ (not (zerop (logand (file-modes
+ (expand-file-name "update-game-score"
+ exec-directory))
+ #o4000)))))
(cond ((file-name-absolute-p file)
(gamegrid-add-score-insecure file score))
((and gamegrid-shared-game-dir
(defun gametree-children-shown-p ()
(save-excursion
- (condition-case nil
+ (ignore-errors
(let ((depth (gametree-current-branch-depth)))
(outline-next-visible-heading 1)
- (< depth (gametree-current-branch-depth)))
- (error nil))))
+ (< depth (gametree-current-branch-depth))))))
-(defun gametree-current-layout (depth &optional top-level)
+(defun gametree-current-layout (depth &optional from-top-level)
(let ((layout nil) (first-time t))
(while (save-excursion
- (condition-case nil
- (progn
- (or (and first-time top-level
- (bolp) (looking-at outline-regexp))
- (setq first-time nil)
- (outline-next-visible-heading 1))
- (< depth (gametree-current-branch-depth)))
- (error nil)))
+ (ignore-errors
+ (or (and first-time from-top-level
+ (bolp) (looking-at outline-regexp))
+ (setq first-time nil)
+ (outline-next-visible-heading 1))
+ (< depth (gametree-current-branch-depth))))
(if (not first-time)
(outline-next-visible-heading 1))
(setq first-time nil)
(goto-char (point-min))
(setq gametree-local-layout (gametree-current-layout 0 t))))
-(defun gametree-apply-layout (layout depth &optional top-level)
+(defun gametree-apply-layout (layout depth &optional from-top-level)
(let ((first-time t))
(while (and layout
(save-excursion
- (condition-case nil
- (progn
- (or (and first-time top-level
- (bolp) (looking-at outline-regexp))
- (setq first-time nil)
- (outline-next-visible-heading 1))
- (< depth (gametree-current-branch-depth)))
- (error nil))))
+ (ignore-errors
+ (or (and first-time from-top-level
+ (bolp) (looking-at outline-regexp))
+ (setq first-time nil)
+ (outline-next-visible-heading 1))
+ (< depth (gametree-current-branch-depth)))))
(if (not first-time)
(outline-next-visible-heading 1))
(setq first-time nil)
(while (not done) ;handle subheadings
(setq running (funcall minmax running
(gametree-compute-reduced-score)))
- (setq done (condition-case nil
- (outline-forward-same-level 1)
- (error nil)))))
+ (setq done (ignore-errors (outline-forward-same-level 1)))))
running)))))
\f
;;;; Commands
(insert-char ?\n gomoku-square-height))
(or (eq (char-after 1) ?.)
(put-text-property 1 2 'point-entered
- (lambda (x y) (if (bobp) (forward-char)))))
+ (lambda (_x _y) (if (bobp) (forward-char)))))
(or intangible
(put-text-property point (point) 'intangible 2))
(put-text-property point (point) 'point-entered
- (lambda (x y) (if (eobp) (backward-char))))
+ (lambda (_x _y) (if (eobp) (backward-char))))
(put-text-property (point-min) (point) 'category 'gomoku-mode))
(gomoku-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board
(sit-for 0)) ; Display NOW
;;; Code:
+;; From ps-print.el
(defvar ps-printer-name)
(defvar ps-lpr-command)
+(defvar ps-lpr-switches)
;; Variables
`handwrite-pagenumbering' (default nil)"
(interactive)
(let
- ((pmin) ; thanks, Havard
- (lastp)
+ (;(pmin) ; thanks, Havard
(cur-buf (current-buffer))
(tpoint (point))
(ps-ypos 63)
(fly-steps (abs (/ (- (cdr to) (cdr from)) fly-step)))
(directed-fly-step (/ (- (cdr to) (cdr from)) fly-steps))
(baseward-steps (/ (- (car to) (cdr to)) baseward-step))
- (total-steps (+ flyward-steps fly-steps baseward-steps))
;; A step is a character cell. A tick is a time-unit. To
;; make horizontal and vertical motion appear roughly the
;; same speed, we allow one tick per horizontal step and two
(insert-char ?\n landmark-square-height))
(or (eq (char-after 1) ?.)
(put-text-property 1 2 'point-entered
- (lambda (x y) (if (bobp) (forward-char)))))
+ (lambda (_x _y) (if (bobp) (forward-char)))))
(or intangible
(put-text-property point (point) 'intangible 2))
(put-text-property point (point) 'point-entered
- (lambda (x y) (if (eobp) (backward-char))))
+ (lambda (_x _y) (if (eobp) (backward-char))))
(put-text-property (point-min) (point) 'category 'landmark-mode))
(landmark-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board
(sit-for 0)) ; Display NOW
(t x)))
(defun landmark-y (direction)
- (let ((noise (put direction 'noise (landmark-noise))))
- (put direction 'y_t
- (if (> (get direction 's) 0.0)
- 1.0
- 0.0))))
+ (put direction 'noise (landmark-noise))
+ (put direction 'y_t
+ (if (> (get direction 's) 0.0)
+ 1.0
+ 0.0)))
(defun landmark-update-normal-weights (direction)
(mapc (lambda (target-direction)
landmark-directions))
(defun landmark-update-naught-weights (direction)
- (mapc (lambda (target-direction)
+ (mapc (lambda (_target-direction)
(put direction 'w0
(landmark-f
(+
((not landmark-game-in-progress)
(landmark-prompt-for-other-game))
(t
- (let (square score)
+ (let (square)
(setq square (landmark-point-square))
(cond ((null square)
(error "Your point is not on a square. Retry!"))
"Propose a digit for a letter in puzzle."
(interactive)
(if mpuz-in-progress
- (let (letter-char digit digit-char message)
+ (let (letter-char digit digit-char)
(setq letter-char (upcase last-command-event)
digit (mpuz-to-digit (- letter-char ?A)))
(cond ((mpuz-digit-solved-p digit)
"Propose LETTER-CHAR as code for DIGIT-CHAR."
(let* ((letter (- letter-char ?A))
(digit (- digit-char ?0))
- (correct-digit (mpuz-to-digit letter))
- (game mpuz-nb-completed-games))
+ (correct-digit (mpuz-to-digit letter)))
(cond ((mpuz-digit-solved-p correct-digit)
(message "%c has already been found." (+ correct-digit ?0)))
((mpuz-digit-solved-p digit)
'(solitaire-left solitaire-right solitaire-up solitaire-down))
;;;###autoload
-(defun solitaire (arg)
+(defun solitaire (_arg)
"Play Solitaire.
To play Solitaire, type \\[solitaire].
solitaire-valid-directions)))
count))))
-(defun solitaire-do-check (&optional arg)
+(defun solitaire-do-check (&optional _arg)
"Check for any possible moves in Solitaire."
(interactive "P")
(let ((moves (solitaire-check)))
;; ;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst tetris-shapes
- [[[[0 0] [1 0] [0 1] [1 1]]]
-
- [[[0 0] [1 0] [2 0] [2 1]]
- [[1 -1] [1 0] [1 1] [0 1]]
- [[0 -1] [0 0] [1 0] [2 0]]
- [[1 -1] [2 -1] [1 0] [1 1]]]
-
- [[[0 0] [1 0] [2 0] [0 1]]
- [[0 -1] [1 -1] [1 0] [1 1]]
- [[2 -1] [0 0] [1 0] [2 0]]
- [[1 -1] [1 0] [1 1] [2 1]]]
-
- [[[0 0] [1 0] [1 1] [2 1]]
+ [[[[0 0] [1 0] [0 1] [1 1]]]
+
+ [[[0 0] [1 0] [2 0] [2 1]]
+ [[1 -1] [1 0] [1 1] [0 1]]
+ [[0 -1] [0 0] [1 0] [2 0]]
+ [[1 -1] [2 -1] [1 0] [1 1]]]
+
+ [[[0 0] [1 0] [2 0] [0 1]]
+ [[0 -1] [1 -1] [1 0] [1 1]]
+ [[2 -1] [0 0] [1 0] [2 0]]
+ [[1 -1] [1 0] [1 1] [2 1]]]
+
+ [[[0 0] [1 0] [1 1] [2 1]]
[[1 0] [0 1] [1 1] [0 2]]]
-
- [[[1 0] [2 0] [0 1] [1 1]]
- [[0 0] [0 1] [1 1] [1 2]]]
-
- [[[1 0] [0 1] [1 1] [2 1]]
- [[1 0] [1 1] [2 1] [1 2]]
- [[0 1] [1 1] [2 1] [1 2]]
+
+ [[[1 0] [2 0] [0 1] [1 1]]
+ [[0 0] [0 1] [1 1] [1 2]]]
+
+ [[[1 0] [0 1] [1 1] [2 1]]
+ [[1 0] [1 1] [2 1] [1 2]]
+ [[0 1] [1 1] [2 1] [1 2]]
[[1 0] [0 1] [1 1] [1 2]]]
-
+
[[[0 0] [1 0] [2 0] [3 0]]
[[1 -1] [1 0] [1 1] [1 2]]]]
- "Each shape is described by a vector that contains the coordinates of
+ "Each shape is described by a vector that contains the coordinates of
each one of its four blocks.")
;;the scoring rules were taken from "xtetris". Blocks score differently
(defconst tetris-space 9)
-(defun tetris-default-update-speed-function (shapes rows)
+(defun tetris-default-update-speed-function (_shapes rows)
(/ 20.0 (+ 50.0 rows)))
;; ;;;;;;;;;;;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(loop for i from 0 to 3 do
(let ((c (tetris-get-shape-cell i)))
(gamegrid-set-cell (+ tetris-top-left-x
- tetris-pos-x
+ tetris-pos-x
(aref c 0))
(+ tetris-top-left-y
- tetris-pos-y
+ tetris-pos-y
(aref c 1))
tetris-blank))))
(unless hit
(setq hit
(let* ((c (tetris-get-shape-cell i))
- (xx (+ tetris-pos-x
+ (xx (+ tetris-pos-x
(aref c 0)))
- (yy (+ tetris-pos-y
+ (yy (+ tetris-pos-y
(aref c 1))))
(or (>= xx tetris-width)
(>= yy tetris-height)
- (/= (gamegrid-get-cell
- (+ xx tetris-top-left-x)
+ (/= (gamegrid-get-cell
+ (+ xx tetris-top-left-x)
(+ yy tetris-top-left-y))
tetris-blank))))))
hit))
(interactive)
(unless tetris-paused
(tetris-erase-shape)
- (setq tetris-rot (% (+ 1 tetris-rot)
+ (setq tetris-rot (% (+ 1 tetris-rot)
(tetris-shape-rotations)))
(if (tetris-test-shape)
- (setq tetris-rot (% (+ 3 tetris-rot)
+ (setq tetris-rot (% (+ 3 tetris-rot)
(tetris-shape-rotations))))
(tetris-draw-shape)))
"*Seconds to wait between successive `life' generations.
If nil, `zone-pgm-random-life' chooses a value from 0-3 (inclusive).")
+(defvar life-patterns) ; from life.el
+
(defun zone-pgm-random-life ()
(require 'life)
(zone-fill-out-screen (1- (window-width)) (1- (window-height)))