[PATCH] elpa/packages/sokoban/sokoban.el

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] elpa/packages/sokoban/sokoban.el

Dieter Deyke-5
===== Commit message: =====

* sokoban.el: Switch to lexical-binding

Switch to lexical-binding

Unrelated additional changes:

- Do not make variables buffer-local for easier debugging

===== Patch: =====

diff --git a/sokoban.el b/sokoban.el
index 4698450..f4a3369 100644
--- a/sokoban.el
+++ b/sokoban.el
@@ -1,10 +1,10 @@
-;;; sokoban.el --- Implementation of Sokoban for Emacs.
+;;; sokoban.el --- Implementation of Sokoban for Emacs. -*- lexical-binding: t -*-
 
-;; Copyright (C) 1998, 2013, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2013, 2017, 2019 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <[hidden email]>
 ;; Maintainer: Dieter Deyke <[hidden email]>
-;; Version: 1.4.6
+;; Version: 1.4.7
 ;; Package-Requires: ((emacs "23.1"))
 ;; Created: 1997-09-11
 ;; Keywords: games
@@ -82,18 +82,7 @@
               (and (file-exists-p file) file))
  (expand-file-name "sokoban.levels" data-directory))))
 
-(defvar sokoban-width)
-(defvar sokoban-height)
-
-(defvar sokoban-buffer-width)
-(defvar sokoban-buffer-height)
-
-(defvar sokoban-score-x)
-(defvar sokoban-score-y)
-
-(defvar sokoban-level-data nil)
-
-(defconst sokoban-state-filename (locate-user-emacs-file "sokoban-state"))
+(defvar sokoban-state-filename (locate-user-emacs-file "sokoban-state"))
 
 ;; ;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -477,28 +466,24 @@ static char * player_on_target_xpm[] = {
 
 ;; ;;;;;;;;;;;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+(defvar sokoban-width)
+(defvar sokoban-height)
+(defvar sokoban-buffer-width)
+(defvar sokoban-buffer-height)
+(defvar sokoban-score-x)
+(defvar sokoban-score-y)
+(defvar sokoban-level-data nil)
 (defvar sokoban-level 0)
-(make-variable-buffer-local 'sokoban-level)
 (defvar sokoban-level-map nil)
-(make-variable-buffer-local 'sokoban-level-map)
 (defvar sokoban-targets 0)
-(make-variable-buffer-local 'sokoban-targets)
 (defvar sokoban-x 0)
-(make-variable-buffer-local 'sokoban-x)
 (defvar sokoban-y 0)
-(make-variable-buffer-local 'sokoban-y)
 (defvar sokoban-moves 0)
-(make-variable-buffer-local 'sokoban-moves)
 (defvar sokoban-pushes 0)
-(make-variable-buffer-local 'sokoban-pushes)
 (defvar sokoban-done 0)
-(make-variable-buffer-local 'sokoban-done)
 (defvar sokoban-mouse-x 0)
-(make-variable-buffer-local 'sokoban-mouse-x)
 (defvar sokoban-mouse-y 0)
-(make-variable-buffer-local 'sokoban-mouse-y)
 (defvar sokoban-undo-list nil)
-(make-variable-buffer-local 'sokoban-undo-list)
 
 ;; ;;;;;;;;;;;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -650,7 +635,7 @@ static char * player_on_target_xpm[] = {
   (let ((y sokoban-score-y))
     (dolist (string (list (format "Moves:  %05d" sokoban-moves)
   (format "Pushes: %05d" sokoban-pushes)
-  (format "Done:   %d/%d"
+  (format "Done:   %d/%d "
   sokoban-done
   sokoban-targets)))
       (let* ((len (length string)))
@@ -762,9 +747,8 @@ static char * player_on_target_xpm[] = {
  (incf sokoban-done))
     (sokoban-add-push dx dy)
     (cond ((= sokoban-done sokoban-targets)
-                           (let ((level sokoban-level))
-                             (with-temp-file sokoban-state-filename
-                               (print level (current-buffer))))
+                           (with-temp-file sokoban-state-filename
+                             (print sokoban-level (current-buffer)))
    (sit-for 3)
    (sokoban-next-level))))))))))
 

--
Dieter Deyke
mailto:[hidden email]
Get my Gnupg key:
gpg --keyserver keys.gnupg.net --recv-keys B116EA20


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Clément Pit-Claudel
On 07/02/2019 05.51, Dieter Deyke wrote:
>
> - Do not make variables buffer-local for easier debugging

Were these variables made buffer-local to allow multiple games at once, maybe?

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Eli Zaretskii
> From: Clément Pit-Claudel <[hidden email]>
> Date: Thu, 7 Feb 2019 07:53:08 -0500
>
> On 07/02/2019 05.51, Dieter Deyke wrote:
> >
> > - Do not make variables buffer-local for easier debugging
>
> Were these variables made buffer-local to allow multiple games at once, maybe?

Indeed, I don't understand why it's a good idea to make this
particular change.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Stefan Monnier
In reply to this post by Dieter Deyke-5
> - Do not make variables buffer-local for easier debugging

I think this is a mistake.


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Dieter Deyke-5
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> From: Clément Pit-Claudel <[hidden email]>
>> Date: Thu, 7 Feb 2019 07:53:08 -0500
>>
>> On 07/02/2019 05.51, Dieter Deyke wrote:
>> >
>> > - Do not make variables buffer-local for easier debugging
>>
>> Were these variables made buffer-local to allow multiple games at once, maybe?
>
> Indeed, I don't understand why it's a good idea to make this
> particular change.

I found it easier to query the values of those variables from other
windows when they were not buffer-local, but I can always make that
change for debugging and retract it afterwards. Or is there some other
trick?

--
Dieter Deyke
mailto:[hidden email]
Get my Gnupg key:
gpg --keyserver keys.gnupg.net --recv-keys B116EA20

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Clément Pit-Claudel
On 07/02/2019 10.57, Dieter Deyke wrote:
> I found it easier to query the values of those variables from other
> windows when they were not buffer-local

I find the buffer-local-value function useful for these cases.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Dieter Deyke-5
Clément Pit-Claudel <[hidden email]> writes:

> On 07/02/2019 10.57, Dieter Deyke wrote:
>> I found it easier to query the values of those variables from other
>> windows when they were not buffer-local
>
> I find the buffer-local-value function useful for these cases.

Cool. I did not know this one, thanks!

--
Dieter Deyke
mailto:[hidden email]
Get my Gnupg key:
gpg --keyserver keys.gnupg.net --recv-keys B116EA20

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Andreas Schwab
In reply to this post by Dieter Deyke-5
On Feb 07 2019, Dieter Deyke <[hidden email]> wrote:

> I found it easier to query the values of those variables from other
> windows when they were not buffer-local, but I can always make that
> change for debugging and retract it afterwards. Or is there some other
> trick?

The easiest way is to run ielm, then attach it to the buffer with
ielm-change-working-buffer.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elpa/packages/sokoban/sokoban.el

Stefan Monnier
>> I found it easier to query the values of those variables from other
>> windows when they were not buffer-local, but I can always make that
>> change for debugging and retract it afterwards. Or is there some other
>> trick?
> The easiest way is to run ielm, then attach it to the buffer with
> ielm-change-working-buffer.

Indeed, I typically use this, or use `M-:` in the appropriate window
(or use `e` in the debugger).


        Stefan