From 121656e9e3bd049f75d979360295a60944ff19d6 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 21 Apr 2011 14:24:46 +0200 Subject: [PATCH] lisp/play/*.el: Lexical-binding cleanup. --- lisp/ChangeLog | 48 +++++++++++++++++ lisp/play/5x5.el | 6 +-- lisp/play/bubbles.el | 16 +++--- lisp/play/decipher.el | 53 ++++++++++--------- lisp/play/doctor.el | 114 ++++++++++++++++++++--------------------- lisp/play/fortune.el | 2 +- lisp/play/gamegrid.el | 11 ++-- lisp/play/gametree.el | 41 ++++++--------- lisp/play/gomoku.el | 4 +- lisp/play/handwrite.el | 5 +- lisp/play/hanoi.el | 1 - lisp/play/landmark.el | 18 +++---- lisp/play/mpuz.el | 5 +- lisp/play/solitaire.el | 4 +- lisp/play/tetris.el | 62 +++++++++++----------- lisp/play/zone.el | 2 + 16 files changed, 215 insertions(+), 177 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ea762d06982..e359a0f7cc5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,51 @@ +2011-04-21 Juanma Barranquero + + 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 * vc/vc.el (ediff-vc-internal): Declare function. diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el index 364ea35af3c..46c3c867304 100644 --- a/lisp/play/5x5.el +++ b/lisp/play/5x5.el @@ -368,15 +368,15 @@ should return a grid vector array that is the new solution." (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)) diff --git a/lisp/play/bubbles.el b/lisp/play/bubbles.el index 0dc556007ba..f2b7294e2d0 100644 --- a/lisp/play/bubbles.el +++ b/lisp/play/bubbles.el @@ -1,4 +1,4 @@ -;;; bubbles.el --- Puzzle game for Emacs. +;;; bubbles.el --- Puzzle game for Emacs ;; Copyright (C) 2007-2011 Free Software Foundation, Inc. @@ -921,7 +921,8 @@ static char * dot3d_xpm[] = { (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) @@ -1317,8 +1318,7 @@ Use optional parameter POS instead of point if given." 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) @@ -1416,9 +1416,8 @@ Return t if new char is non-empty." (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)) @@ -1434,8 +1433,7 @@ Return t if new char is non-empty." (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) diff --git a/lisp/play/decipher.el b/lisp/play/decipher.el index 3de8ca3d4fd..b9ce669533a 100644 --- a/lisp/play/decipher.el +++ b/lisp/play/decipher.el @@ -353,7 +353,7 @@ The most useful commands are: (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)) @@ -366,10 +366,10 @@ The most useful commands are: (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 @@ -432,12 +432,12 @@ The most useful commands are: ;; 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 @@ -466,15 +466,15 @@ The most useful commands are: (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) @@ -527,8 +527,7 @@ Type `\\[decipher-restore-checkpoint]' to restore a checkpoint." (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) @@ -585,12 +584,12 @@ you have determined the keyword." 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))) @@ -624,7 +623,7 @@ You should use this if you edit the ciphertext." (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) @@ -751,8 +750,8 @@ FUNC is called exactly once between words, with `decipher-char' set to 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 @@ -760,16 +759,16 @@ See `decipher-loop-no-breaks' if you do not care about word divisions." (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) @@ -844,13 +843,13 @@ TOTAL is the total number of letters in the ciphertext." 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)) @@ -883,7 +882,7 @@ TOTAL is the total number of letters in the ciphertext." (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)) @@ -1057,7 +1056,7 @@ if it can't, it signals an error." ;; (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")))))) diff --git a/lisp/play/doctor.el b/lisp/play/doctor.el index c60472e9386..02d24afb278 100644 --- a/lisp/play/doctor.el +++ b/lisp/play/doctor.el @@ -268,7 +268,7 @@ reads the sentence before point, and prints the Doctor's answer." (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 \?) @@ -371,8 +371,8 @@ reads the sentence before point, and prints the Doctor's answer." (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) \.\.\. \?))) @@ -384,11 +384,11 @@ reads the sentence before point, and prints the Doctor's answer." ((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!) @@ -398,15 +398,15 @@ reads the sentence before point, and prints the Doctor's 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 \?) @@ -415,7 +415,7 @@ reads the sentence before point, and prints the Doctor's answer." '((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)) @@ -859,25 +859,25 @@ Otherwise call the Doctor to parse preceding sentence." ;; 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 "," @@ -889,29 +889,29 @@ Otherwise call the Doctor to parse preceding sentence." '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)) @@ -920,9 +920,9 @@ Otherwise call the Doctor to parse preceding sentence." (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)))))))) ;; Things done to process sentences once read. @@ -1130,8 +1130,8 @@ the subject noun, and return the portion of the sentence following it." (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) @@ -1304,7 +1304,7 @@ element pair in RLIST." 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))) @@ -1327,8 +1327,8 @@ and DOCTOR-OBJ." (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) @@ -1414,7 +1414,7 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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 () @@ -1426,14 +1426,14 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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)) @@ -1497,10 +1497,10 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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)) @@ -1511,8 +1511,8 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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\; @@ -1523,14 +1523,14 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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) @@ -1564,7 +1564,7 @@ Hack on previous word, setting global variable DOCTOR-OWNER to correct result." (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)))) diff --git a/lisp/play/fortune.el b/lisp/play/fortune.el index 05775c8a85e..a61b52f4ad1 100644 --- a/lisp/play/fortune.el +++ b/lisp/play/fortune.el @@ -282,7 +282,7 @@ and choose the directory as the fortune-file." ;;; ************** ;;; 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." diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index 99e3b487437..e245e70a55c 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -485,12 +485,11 @@ FILE is created there." (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 diff --git a/lisp/play/gametree.el b/lisp/play/gametree.el index cd353d27f07..4d514d2d0aa 100644 --- a/lisp/play/gametree.el +++ b/lisp/play/gametree.el @@ -258,23 +258,20 @@ This value is simply the outline heading level of the current line." (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) @@ -297,18 +294,16 @@ This value is simply the outline heading level of the current line." (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) @@ -375,9 +370,7 @@ Subnodes which have been manually scored are honored." (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))))) ;;;; Commands diff --git a/lisp/play/gomoku.el b/lisp/play/gomoku.el index f9d5594cd0b..33fcf451ebb 100644 --- a/lisp/play/gomoku.el +++ b/lisp/play/gomoku.el @@ -1043,11 +1043,11 @@ If the game is finished, this command requests for another game." (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 diff --git a/lisp/play/handwrite.el b/lisp/play/handwrite.el index 601232e4321..70c10da5405 100644 --- a/lisp/play/handwrite.el +++ b/lisp/play/handwrite.el @@ -67,8 +67,10 @@ ;;; Code: +;; From ps-print.el (defvar ps-printer-name) (defvar ps-lpr-command) +(defvar ps-lpr-switches) ;; Variables @@ -157,8 +159,7 @@ Variables: `handwrite-linespace' (default 12) `handwrite-pagenumbering' (default nil)" (interactive) (let - ((pmin) ; thanks, Havard - (lastp) + (;(pmin) ; thanks, Havard (cur-buf (current-buffer)) (tpoint (point)) (ps-ypos 63) diff --git a/lisp/play/hanoi.el b/lisp/play/hanoi.el index 767792babb3..ac78a86757c 100644 --- a/lisp/play/hanoi.el +++ b/lisp/play/hanoi.el @@ -355,7 +355,6 @@ BITS must be of length nrings. Start at START-TIME." (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 diff --git a/lisp/play/landmark.el b/lisp/play/landmark.el index dd32fd790d3..f0e6670fe58 100644 --- a/lisp/play/landmark.el +++ b/lisp/play/landmark.el @@ -943,11 +943,11 @@ mouse-1: get robot moving, mouse-2: play on this square"))) (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 @@ -1377,11 +1377,11 @@ After this limit is reached, landmark-random-move is called to push him out of i (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) @@ -1395,7 +1395,7 @@ After this limit is reached, landmark-random-move is called to push him out of i landmark-directions)) (defun landmark-update-naught-weights (direction) - (mapc (lambda (target-direction) + (mapc (lambda (_target-direction) (put direction 'w0 (landmark-f (+ @@ -1513,7 +1513,7 @@ If the game is finished, this command requests for another game." ((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!")) diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el index 269da0a061c..5f4ecce31ca 100644 --- a/lisp/play/mpuz.el +++ b/lisp/play/mpuz.el @@ -425,7 +425,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." "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) @@ -454,8 +454,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." "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) diff --git a/lisp/play/solitaire.el b/lisp/play/solitaire.el index 2fe62ed0e60..722c3b43033 100644 --- a/lisp/play/solitaire.el +++ b/lisp/play/solitaire.el @@ -126,7 +126,7 @@ the game is over, or off, if you are working on a slow machine." '(solitaire-left solitaire-right solitaire-up solitaire-down)) ;;;###autoload -(defun solitaire (arg) +(defun solitaire (_arg) "Play Solitaire. To play Solitaire, type \\[solitaire]. @@ -393,7 +393,7 @@ which a stone will be taken away) and target." 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))) diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el index 2935ff04c96..053b07adfc7 100644 --- a/lisp/play/tetris.el +++ b/lisp/play/tetris.el @@ -193,32 +193,32 @@ If the return value is a number, it is used as the timer period." ;; ;;;;;;;;;;;;; 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 @@ -236,7 +236,7 @@ each one of its four blocks.") (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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -380,10 +380,10 @@ each one of its four blocks.") (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)))) @@ -393,14 +393,14 @@ each one of its four blocks.") (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)) @@ -537,10 +537,10 @@ Drops the shape one square, testing for collision." (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))) diff --git a/lisp/play/zone.el b/lisp/play/zone.el index 75c3b6fbc7d..d194a8af919 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -626,6 +626,8 @@ If the element is a function or a list of a function and a number, "*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))) -- 2.39.2