Prefer defvar-local in play/*.el

* lisp/play/5x5.el
(5x5-grid, 5x5-x-pos, 5x5-y-pos, 5x5-moves, 5x5-cracking):
* lisp/play/decipher.el (decipher-alphabet)
(decipher-stats-buffer, decipher-undo-list-size)
(decipher-undo-list):
* lisp/play/gamegrid.el (gamegrid-use-glyphs)
(gamegrid-use-color, gamegrid-font, gamegrid-face)
(gamegrid-display-options, gamegrid-buffer-width)
(gamegrid-buffer-height, gamegrid-blank, gamegrid-timer)
(gamegrid-display-mode, gamegrid-display-table)
(gamegrid-face-table, gamegrid-buffer-start)
(gamegrid-score-file-length):
* lisp/play/snake.el (snake-length, snake-velocity-x)
(snake-velocity-y, snake-positions, snake-score, snake-paused)
(snake-moved-p, snake-velocity-queue):
* lisp/play/tetris.el (tetris-shape, tetris-rot)
(tetris-next-shape, tetris-n-shapes, tetris-n-rows)
(tetris-score, tetris-pos-x, tetris-pos-y, tetris-paused):
Prefer defvar-local.

* lisp/play/5x5.el (5x5-defvar-local): Make obsolete.
This commit is contained in:
Stefan Kangas 2021-01-31 05:27:06 +01:00
parent e226357c3b
commit 31ec1a7d32
5 changed files with 41 additions and 78 deletions

View file

@ -84,23 +84,24 @@
(defmacro 5x5-defvar-local (var value doc)
"Define VAR to VALUE with documentation DOC and make it buffer local."
(declare (obsolete defvar-local "28.1"))
`(progn
(defvar ,var ,value ,doc)
(make-variable-buffer-local (quote ,var))))
(5x5-defvar-local 5x5-grid nil
(defvar-local 5x5-grid nil
"5x5 grid contents.")
(5x5-defvar-local 5x5-x-pos 2
(defvar-local 5x5-x-pos 2
"X position of cursor.")
(5x5-defvar-local 5x5-y-pos 2
(defvar-local 5x5-y-pos 2
"Y position of cursor.")
(5x5-defvar-local 5x5-moves 0
(defvar-local 5x5-moves 0
"Moves made.")
(5x5-defvar-local 5x5-cracking nil
(defvar-local 5x5-cracking nil
"Are we in cracking mode?")
(defvar 5x5-buffer-name "*5x5*"

View file

@ -184,28 +184,24 @@ the tail of the list."
(cl-incf c))
(setq decipher-mode-syntax-table table)))
(defvar decipher-alphabet nil)
(defvar-local decipher-alphabet nil)
;; This is an alist containing entries (PLAIN-CHAR . CIPHER-CHAR),
;; where PLAIN-CHAR runs from ?a to ?z and CIPHER-CHAR is an uppercase
;; letter or space (which means no mapping is known for that letter).
;; This *must* contain entries for all lowercase characters.
(make-variable-buffer-local 'decipher-alphabet)
(defvar decipher-stats-buffer nil
(defvar-local decipher-stats-buffer nil
"The buffer which displays statistics for this ciphertext.
Do not access this variable directly, use the function
`decipher-stats-buffer' instead.")
(make-variable-buffer-local 'decipher-stats-buffer)
(defvar decipher-undo-list-size 0
(defvar-local decipher-undo-list-size 0
"The number of entries in the undo list.")
(make-variable-buffer-local 'decipher-undo-list-size)
(defvar decipher-undo-list nil
(defvar-local decipher-undo-list nil
"The undo list for this buffer.
Each element is either a cons cell (PLAIN-CHAR . CIPHER-CHAR) or a
list of such cons cells.")
(make-variable-buffer-local 'decipher-undo-list)
(defvar decipher-pending-undo-list nil)

View file

@ -28,36 +28,35 @@
;; ;;;;;;;;;;;;; buffer-local variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar gamegrid-use-glyphs t
(defvar-local gamegrid-use-glyphs t
"Non-nil means use glyphs when available.")
(defvar gamegrid-use-color t
(defvar-local gamegrid-use-color t
"Non-nil means use color when available.")
(defvar gamegrid-font "-*-courier-medium-r-*-*-*-140-100-75-*-*-iso8859-*"
(defvar-local gamegrid-font "-*-courier-medium-r-*-*-*-140-100-75-*-*-iso8859-*"
"Name of the font used in X mode.")
(defvar gamegrid-face nil
(defvar-local gamegrid-face nil
"Indicates the face to use as a default.")
(make-variable-buffer-local 'gamegrid-face)
(defvar gamegrid-display-options nil)
(defvar-local gamegrid-display-options nil)
(defvar gamegrid-buffer-width 0)
(defvar gamegrid-buffer-height 0)
(defvar gamegrid-blank 0)
(defvar-local gamegrid-buffer-width 0)
(defvar-local gamegrid-buffer-height 0)
(defvar-local gamegrid-blank 0)
(defvar gamegrid-timer nil)
(defvar-local gamegrid-timer nil)
(defvar gamegrid-display-mode nil)
(defvar-local gamegrid-display-mode nil)
(defvar gamegrid-display-table)
(defvar-local gamegrid-display-table)
(defvar gamegrid-face-table nil)
(defvar-local gamegrid-face-table nil)
(defvar gamegrid-buffer-start 1)
(defvar-local gamegrid-buffer-start 1)
(defvar gamegrid-score-file-length 50
(defvar-local gamegrid-score-file-length 50
"Number of high scores to keep.")
(defvar gamegrid-user-score-file-directory
@ -66,19 +65,6 @@
If Emacs was built without support for shared game scores, then this
directory will be used.")
(make-variable-buffer-local 'gamegrid-use-glyphs)
(make-variable-buffer-local 'gamegrid-use-color)
(make-variable-buffer-local 'gamegrid-font)
(make-variable-buffer-local 'gamegrid-display-options)
(make-variable-buffer-local 'gamegrid-buffer-width)
(make-variable-buffer-local 'gamegrid-buffer-height)
(make-variable-buffer-local 'gamegrid-blank)
(make-variable-buffer-local 'gamegrid-timer)
(make-variable-buffer-local 'gamegrid-display-mode)
(make-variable-buffer-local 'gamegrid-display-table)
(make-variable-buffer-local 'gamegrid-face-table)
(make-variable-buffer-local 'gamegrid-buffer-start)
(make-variable-buffer-local 'gamegrid-score-file-length)
;; ;;;;;;;;;;;;; global variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -140,14 +140,14 @@
;; ;;;;;;;;;;;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar snake-length 0)
(defvar snake-velocity-x 1)
(defvar snake-velocity-y 0)
(defvar snake-positions nil)
(defvar snake-score 0)
(defvar snake-paused nil)
(defvar snake-moved-p nil)
(defvar snake-velocity-queue nil
(defvar-local snake-length 0)
(defvar-local snake-velocity-x 1)
(defvar-local snake-velocity-y 0)
(defvar-local snake-positions nil)
(defvar-local snake-score 0)
(defvar-local snake-paused nil)
(defvar-local snake-moved-p nil)
(defvar-local snake-velocity-queue nil
"This queue stores the velocities requested too quickly by user.
They will take effect one at a time at each clock-interval.
This is necessary for proper behavior.
@ -158,16 +158,6 @@ we implemented all your keystrokes immediately, the snake would
effectively never move up. Thus, we need to move it up for one turn
and then start moving it leftwards.")
(make-variable-buffer-local 'snake-length)
(make-variable-buffer-local 'snake-velocity-x)
(make-variable-buffer-local 'snake-velocity-y)
(make-variable-buffer-local 'snake-positions)
(make-variable-buffer-local 'snake-score)
(make-variable-buffer-local 'snake-paused)
(make-variable-buffer-local 'snake-moved-p)
(make-variable-buffer-local 'snake-velocity-queue)
;; ;;;;;;;;;;;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar snake-mode-map

View file

@ -224,25 +224,15 @@ each one of its four blocks.")
;; ;;;;;;;;;;;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar tetris-shape 0)
(defvar tetris-rot 0)
(defvar tetris-next-shape 0)
(defvar tetris-n-shapes 0)
(defvar tetris-n-rows 0)
(defvar tetris-score 0)
(defvar tetris-pos-x 0)
(defvar tetris-pos-y 0)
(defvar tetris-paused nil)
(make-variable-buffer-local 'tetris-shape)
(make-variable-buffer-local 'tetris-rot)
(make-variable-buffer-local 'tetris-next-shape)
(make-variable-buffer-local 'tetris-n-shapes)
(make-variable-buffer-local 'tetris-n-rows)
(make-variable-buffer-local 'tetris-score)
(make-variable-buffer-local 'tetris-pos-x)
(make-variable-buffer-local 'tetris-pos-y)
(make-variable-buffer-local 'tetris-paused)
(defvar-local tetris-shape 0)
(defvar-local tetris-rot 0)
(defvar-local tetris-next-shape 0)
(defvar-local tetris-n-shapes 0)
(defvar-local tetris-n-rows 0)
(defvar-local tetris-score 0)
(defvar-local tetris-pos-x 0)
(defvar-local tetris-pos-y 0)
(defvar-local tetris-paused nil)
;; ;;;;;;;;;;;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;