From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] elpa/packages/sokoban/sokoban.el Date: Sun, 16 Jul 2017 12:01:41 -0400 Message-ID: References: <87k2385v0g.fsf@deyke2> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500220934 5577 195.159.176.226 (16 Jul 2017 16:02:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Jul 2017 16:02:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 16 18:02:07 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dWlzf-0000rV-ET for ged-emacs-devel@m.gmane.org; Sun, 16 Jul 2017 18:02:03 +0200 Original-Received: from localhost ([::1]:45679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWlzk-0003om-Mi for ged-emacs-devel@m.gmane.org; Sun, 16 Jul 2017 12:02:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWlzW-0003nY-OH for emacs-devel@gnu.org; Sun, 16 Jul 2017 12:01:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWlzS-0001sM-Ry for emacs-devel@gnu.org; Sun, 16 Jul 2017 12:01:54 -0400 Original-Received: from [195.159.176.226] (port=45109 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWlzS-0001qZ-MA for emacs-devel@gnu.org; Sun, 16 Jul 2017 12:01:50 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dWlzK-0008Co-EE for emacs-devel@gnu.org; Sun, 16 Jul 2017 18:01:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 108 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:2m6tyXix+E+pS61U9FgJNGHz4hE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216734 Archived-At: > Determine sokoban-width and sokoban-height dynamically > This avoids hard-coding sokoban-width and sokoban-height by scanning the > level file and finding the correct values dynamically. Looks good to me. I'd document also the (apparently) unrelated changes included, such as the removal of sokoban-temp-buffer-name and the change to sokoban-next-level. Stefan > diff --git a/sokoban.el b/sokoban.el > index 3ac1b6e..d29b134 100644 > --- a/sokoban.el > +++ b/sokoban.el > @@ -4,7 +4,7 @@ > ;; Author: Glynn Clements > ;; Maintainer: Dieter Deyke > -;; Version: 1.4.2 > +;; Version: 1.4.3 > ;; Created: 1997-09-11 > ;; Keywords: games > ;; Package-Type: multi > @@ -71,8 +71,6 @@ > (defvar sokoban-buffer-name "*Sokoban*") > -(defvar sokoban-temp-buffer-name " Sokoban-tmp") > - > (defvar sokoban-level-file > (if (fboundp 'locate-data-file) > (locate-data-file "sokoban.levels") > @@ -84,14 +82,14 @@ > (and (file-exists-p file) file)) > (expand-file-name "sokoban.levels" data-directory)))) > -(defvar sokoban-width 27) > -(defvar sokoban-height 20) > +(defvar sokoban-width) > +(defvar sokoban-height) > -(defvar sokoban-buffer-width sokoban-width) > -(defvar sokoban-buffer-height (+ 4 sokoban-height)) > +(defvar sokoban-buffer-width) > +(defvar sokoban-buffer-height) > -(defvar sokoban-score-x 0) > -(defvar sokoban-score-y (1+ sokoban-height)) > +(defvar sokoban-score-x) > +(defvar sokoban-score-y) > (defvar sokoban-level-data nil) > @@ -542,6 +540,28 @@ static char * player_on_target_xpm[] = { > (if (fboundp 'read-only-mode) > (read-only-mode 1) > (setq buffer-read-only t)) > + > + (setq sokoban-width 1 > + sokoban-height 1) > + (goto-char (point-min)) > + (re-search-forward sokoban-level-regexp nil t) > + (forward-char) > + (let (r) > + (while (not (eobp)) > + (while (looking-at sokoban-comment-regexp) > + (forward-line)) > + (setq r 0) > + (while (not (or (eobp) > + (looking-at sokoban-comment-regexp))) > + (incf r) > + (setq sokoban-height (max sokoban-height r) > + sokoban-width (max sokoban-width (- (line-end-position) (line-beginning-position)))) > + (forward-line)))) > + (setq sokoban-buffer-width sokoban-width > + sokoban-buffer-height (+ 4 sokoban-height) > + sokoban-score-x 0 > + sokoban-score-y (1+ sokoban-height)) > + > (goto-char (point-min)) > (re-search-forward sokoban-level-regexp nil t) > (forward-char) > @@ -823,8 +843,7 @@ static char * player_on_target_xpm[] = { > (sokoban-draw-score)) > (defun sokoban-next-level () > - (incf sokoban-level) > - (sokoban-restart-level)) > + (sokoban-goto-level (1+ sokoban-level))) > (defun sokoban-goto-level (level) > "Jump to a specified LEVEL." > @@ -915,4 +934,3 @@ sokoban-mode keybindings: > (provide 'sokoban) > ;;; sokoban.el ends here > - > -- > Dieter Deyke > mailto:dieter.deyke@gmail.com > Get my Gnupg key: > gpg --keyserver keys.gnupg.net --recv-keys B116EA20