From: Stefan Kangas Date: Sun, 31 Jan 2021 04:27:06 +0000 (+0100) Subject: Prefer defvar-local in play/*.el X-Git-Tag: emacs-28.0.90~4014 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=31ec1a7d329cc9374b16c5831d30248c99e93dfb;p=emacs.git 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. --- diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el index 07ef30c07d1..c89188c0233 100644 --- a/lisp/play/5x5.el +++ b/lisp/play/5x5.el @@ -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*" diff --git a/lisp/play/decipher.el b/lisp/play/decipher.el index a7a4b89c372..b870bfb4a19 100644 --- a/lisp/play/decipher.el +++ b/lisp/play/decipher.el @@ -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) diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index e540ca723d0..34787d928eb 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/lisp/play/snake.el b/lisp/play/snake.el index 5584bf88103..bed7cea6ee5 100644 --- a/lisp/play/snake.el +++ b/lisp/play/snake.el @@ -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 diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el index 8205d3f79c5..05e4ffe0111 100644 --- a/lisp/play/tetris.el +++ b/lisp/play/tetris.el @@ -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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;