diff options
author | Stefan Kangas <stefan@marxist.se> | 2021-02-10 01:23:41 +0100 |
---|---|---|
committer | Stefan Kangas <stefan@marxist.se> | 2021-02-10 06:25:28 +0100 |
commit | a0451be18b2581f5288e1123ee7bbd2aabccbe52 (patch) | |
tree | 470918583baef39e674912fb9e66174970866250 /lisp/play/cookie1.el | |
parent | ff16c897eadab9bebc58bd0ca0fb5c8e1c237a15 (diff) | |
download | emacs-a0451be18b2581f5288e1123ee7bbd2aabccbe52.tar.gz emacs-a0451be18b2581f5288e1123ee7bbd2aabccbe52.tar.bz2 emacs-a0451be18b2581f5288e1123ee7bbd2aabccbe52.zip |
Use lexical-binding in almost all of play/*.el
* lisp/play/5x5.el: Use lexical-binding.
(5x5-draw-grid-end, 5x5-draw-grid, 5x5-solver)
(5x5-solve-suggest): Silence byte-compiler.
* lisp/play/cookie1.el: Use lexical-binding.
(cookie-shuffle-vector, cookie-apropos): Silence byte-compiler.
* lisp/play/zone.el: Use lexical-binding.
(zone): Convert lambda to proper lexical closure.
(zone-replace-char, zone-fill-out-screen): Silence byte-compiler.
* lisp/play/blackbox.el:
* lisp/play/doctor.el:
* lisp/play/gametree.el:
* lisp/play/hanoi.el: Use lexical-binding.
* test/lisp/play/cookie1-resources/cookies:
* test/lisp/play/cookie1-tests.el: New files.
Diffstat (limited to 'lisp/play/cookie1.el')
-rw-r--r-- | lisp/play/cookie1.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/play/cookie1.el b/lisp/play/cookie1.el index 5255d81e5b1..be35daf4da8 100644 --- a/lisp/play/cookie1.el +++ b/lisp/play/cookie1.el @@ -1,4 +1,4 @@ -;;; cookie1.el --- retrieve random phrases from fortune cookie files +;;; cookie1.el --- retrieve random phrases from fortune cookie files -*- lexical-binding: t -*- ;; Copyright (C) 1993, 2001-2021 Free Software Foundation, Inc. @@ -177,11 +177,12 @@ Argument REQUIRE-MATCH non-nil forces a matching cookie." "Randomly permute the elements of VECTOR (all permutations equally likely)." (let ((len (length vector)) j temp) - (dotimes (i len vector) + (dotimes (i len) (setq j (+ i (random (- len i))) temp (aref vector i)) (aset vector i (aref vector j)) - (aset vector j temp)))) + (aset vector j temp)) + vector)) (define-obsolete-function-alias 'shuffle-vector 'cookie-shuffle-vector "24.4") @@ -204,9 +205,10 @@ If called interactively, or if DISPLAY is non-nil, display a list of matches." (cookie-table-symbol (intern phrase-file cookie-cache)) (string-table (symbol-value cookie-table-symbol)) (matches nil)) - (and (dotimes (i (length string-table) matches) - (and (string-match-p regexp (aref string-table i)) - (setq matches (cons (aref string-table i) matches)))) + (dotimes (i (length string-table)) + (and (string-match-p regexp (aref string-table i)) + (setq matches (cons (aref string-table i) matches)))) + (and matches (setq matches (sort matches 'string-lessp))) (and display (if matches |