diff options
| author | Stefan Monnier | 2018-09-22 19:28:35 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-09-22 19:28:35 -0400 |
| commit | 75386e305f388ff51bc8cf9945f52c29c14427cd (patch) | |
| tree | 132a79ba99da41a6dd992cc42a6ea75eb960d4ca | |
| parent | 0b36041d2a528419982a19940573783ff318c0d4 (diff) | |
| download | emacs-75386e305f388ff51bc8cf9945f52c29c14427cd.tar.gz emacs-75386e305f388ff51bc8cf9945f52c29c14427cd.zip | |
* lisp/play/bubbles.el: Use lexical-binding
| -rw-r--r-- | lisp/play/bubbles.el | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lisp/play/bubbles.el b/lisp/play/bubbles.el index ee2135b9bbe..a54682fff22 100644 --- a/lisp/play/bubbles.el +++ b/lisp/play/bubbles.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; bubbles.el --- Puzzle game for Emacs | 1 | ;;; bubbles.el --- Puzzle game for Emacs -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2007-2018 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2007-2018 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -144,8 +144,7 @@ images the `ascii' theme will be used." | |||
| 144 | (const :tag "Diamonds" diamonds) | 144 | (const :tag "Diamonds" diamonds) |
| 145 | (const :tag "Balls" balls) | 145 | (const :tag "Balls" balls) |
| 146 | (const :tag "Emacs" emacs) | 146 | (const :tag "Emacs" emacs) |
| 147 | (const :tag "ASCII (no images)" ascii)) | 147 | (const :tag "ASCII (no images)" ascii))) |
| 148 | :group 'bubbles) | ||
| 149 | 148 | ||
| 150 | (defconst bubbles--grid-small '(10 . 10) | 149 | (defconst bubbles--grid-small '(10 . 10) |
| 151 | "Predefined small bubbles grid.") | 150 | "Predefined small bubbles grid.") |
| @@ -168,8 +167,7 @@ images the `ascii' theme will be used." | |||
| 168 | (const :tag "Huge" ,bubbles--grid-huge) | 167 | (const :tag "Huge" ,bubbles--grid-huge) |
| 169 | (cons :tag "User defined" | 168 | (cons :tag "User defined" |
| 170 | (integer :tag "Width") | 169 | (integer :tag "Width") |
| 171 | (integer :tag "Height"))) | 170 | (integer :tag "Height")))) |
| 172 | :group 'bubbles) | ||
| 173 | 171 | ||
| 174 | (defconst bubbles--colors-2 '("orange" "violet") | 172 | (defconst bubbles--colors-2 '("orange" "violet") |
| 175 | "Predefined bubbles color list with two colors.") | 173 | "Predefined bubbles color list with two colors.") |
| @@ -194,16 +192,14 @@ types are present." | |||
| 194 | (const :tag "Red, darkgreen, blue, orange" ,bubbles--colors-4) | 192 | (const :tag "Red, darkgreen, blue, orange" ,bubbles--colors-4) |
| 195 | (const :tag "Red, darkgreen, blue, orange, violet" | 193 | (const :tag "Red, darkgreen, blue, orange, violet" |
| 196 | ,bubbles--colors-5) | 194 | ,bubbles--colors-5) |
| 197 | (repeat :tag "User defined" color)) | 195 | (repeat :tag "User defined" color))) |
| 198 | :group 'bubbles) | ||
| 199 | 196 | ||
| 200 | (defcustom bubbles-chars | 197 | (defcustom bubbles-chars |
| 201 | '(?+ ?O ?# ?X ?. ?* ?& ?§) | 198 | '(?+ ?O ?# ?X ?. ?* ?& ?§) |
| 202 | "Characters used for bubbles. | 199 | "Characters used for bubbles. |
| 203 | Note that the actual number of different bubbles is determined by | 200 | Note that the actual number of different bubbles is determined by |
| 204 | the number of colors, see `bubbles-colors'." | 201 | the number of colors, see `bubbles-colors'." |
| 205 | :type '(repeat character) | 202 | :type '(repeat character)) |
| 206 | :group 'bubbles) | ||
| 207 | 203 | ||
| 208 | (defcustom bubbles-shift-mode | 204 | (defcustom bubbles-shift-mode |
| 209 | 'default | 205 | 'default |
| @@ -212,12 +208,10 @@ Available modes are `shift-default' and `shift-always'." | |||
| 212 | :type '(radio (const :tag "Default" default) | 208 | :type '(radio (const :tag "Default" default) |
| 213 | (const :tag "Shifter" always) | 209 | (const :tag "Shifter" always) |
| 214 | ;;(const :tag "Mega Shifter" mega) | 210 | ;;(const :tag "Mega Shifter" mega) |
| 215 | ) | 211 | )) |
| 216 | :group 'bubbles) | ||
| 217 | 212 | ||
| 218 | (defcustom bubbles-mode-hook nil | 213 | (defcustom bubbles-mode-hook nil |
| 219 | "Hook run by Bubbles mode." | 214 | "Hook run by Bubbles mode." |
| 220 | :group 'bubbles | ||
| 221 | :type 'hook) | 215 | :type 'hook) |
| 222 | 216 | ||
| 223 | (defun bubbles-customize () | 217 | (defun bubbles-customize () |
| @@ -898,7 +892,7 @@ static char * dot3d_xpm[] = { | |||
| 898 | ;; bubbles mode map | 892 | ;; bubbles mode map |
| 899 | (defvar bubbles-mode-map | 893 | (defvar bubbles-mode-map |
| 900 | (let ((map (make-sparse-keymap 'bubbles-mode-map))) | 894 | (let ((map (make-sparse-keymap 'bubbles-mode-map))) |
| 901 | ;; (suppress-keymap map t) | 895 | ;; (suppress-keymap map t) |
| 902 | (define-key map "q" 'bubbles-quit) | 896 | (define-key map "q" 'bubbles-quit) |
| 903 | (define-key map "\n" 'bubbles-plop) | 897 | (define-key map "\n" 'bubbles-plop) |
| 904 | (define-key map " " 'bubbles-plop) | 898 | (define-key map " " 'bubbles-plop) |
| @@ -925,7 +919,7 @@ static char * dot3d_xpm[] = { | |||
| 925 | (buffer-disable-undo) | 919 | (buffer-disable-undo) |
| 926 | (force-mode-line-update) | 920 | (force-mode-line-update) |
| 927 | (redisplay) | 921 | (redisplay) |
| 928 | (add-hook 'post-command-hook 'bubbles--mark-neighborhood t t)) | 922 | (add-hook 'post-command-hook #'bubbles--mark-neighborhood t t)) |
| 929 | 923 | ||
| 930 | ;;;###autoload | 924 | ;;;###autoload |
| 931 | (defun bubbles () | 925 | (defun bubbles () |
| @@ -1004,14 +998,14 @@ Set `bubbles--col-offset' and `bubbles--row-offset'." | |||
| 1004 | (list bubbles--row-offset)))) | 998 | (list bubbles--row-offset)))) |
| 1005 | (insert "\n") | 999 | (insert "\n") |
| 1006 | (let ((max-char (length (bubbles--colors)))) | 1000 | (let ((max-char (length (bubbles--colors)))) |
| 1007 | (dotimes (i (bubbles--grid-height)) | 1001 | (dotimes (_ (bubbles--grid-height)) |
| 1008 | (let ((p (point))) | 1002 | (let ((p (point))) |
| 1009 | (insert " ") | 1003 | (insert " ") |
| 1010 | (put-text-property p (point) | 1004 | (put-text-property p (point) |
| 1011 | 'display | 1005 | 'display |
| 1012 | (cons 'space (list :width | 1006 | (cons 'space (list :width |
| 1013 | (list bubbles--col-offset))))) | 1007 | (list bubbles--col-offset))))) |
| 1014 | (dotimes (j (bubbles--grid-width)) | 1008 | (dotimes (_ (bubbles--grid-width)) |
| 1015 | (let* ((index (random max-char)) | 1009 | (let* ((index (random max-char)) |
| 1016 | (char (nth index bubbles-chars))) | 1010 | (char (nth index bubbles-chars))) |
| 1017 | (insert char) | 1011 | (insert char) |
| @@ -1268,7 +1262,7 @@ Use optional parameter POS instead of point if given." | |||
| 1268 | (while (get-text-property (point) 'removed) | 1262 | (while (get-text-property (point) 'removed) |
| 1269 | (setq shifted-cols (1+ shifted-cols)) | 1263 | (setq shifted-cols (1+ shifted-cols)) |
| 1270 | (bubbles--shift 'right (1- (bubbles--grid-height)) j)) | 1264 | (bubbles--shift 'right (1- (bubbles--grid-height)) j)) |
| 1271 | (dotimes (k shifted-cols) | 1265 | (dotimes (_ shifted-cols) |
| 1272 | (let ((i (- (bubbles--grid-height) 2))) | 1266 | (let ((i (- (bubbles--grid-height) 2))) |
| 1273 | (while (>= i 0) | 1267 | (while (>= i 0) |
| 1274 | (setq shifted (or (bubbles--shift 'right i j) | 1268 | (setq shifted (or (bubbles--shift 'right i j) |
| @@ -1422,8 +1416,8 @@ Return t if new char is non-empty." | |||
| 1422 | (goto-char (point-min)) | 1416 | (goto-char (point-min)) |
| 1423 | (forward-line 1) | 1417 | (forward-line 1) |
| 1424 | (let ((inhibit-read-only t)) | 1418 | (let ((inhibit-read-only t)) |
| 1425 | (dotimes (i (bubbles--grid-height)) | 1419 | (dotimes (_ (bubbles--grid-height)) |
| 1426 | (dotimes (j (bubbles--grid-width)) | 1420 | (dotimes (_ (bubbles--grid-width)) |
| 1427 | (forward-char 1) | 1421 | (forward-char 1) |
| 1428 | (let ((index (or (get-text-property (point) 'index) -1))) | 1422 | (let ((index (or (get-text-property (point) 'index) -1))) |
| 1429 | (let ((img bubbles--empty-image)) | 1423 | (let ((img bubbles--empty-image)) |