From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lele Gaifax Newsgroups: gmane.emacs.help Subject: How can avoid "assignment to free variable" warning? Date: Tue, 15 Apr 2014 01:43:09 +0200 Organization: Nautilus Entertainments Message-ID: <87tx9vlboy.fsf_-_@nautilus.nautilus> References: <877gdswvje.fsf@informatimago.com> <87mwfqjfri.fsf@nautilus.nautilus> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1397519043 516 80.91.229.3 (14 Apr 2014 23:44:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Apr 2014 23:44:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 15 01:43:55 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WZqXY-0005yO-L3 for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Apr 2014 01:43:52 +0200 Original-Received: from localhost ([::1]:46088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZqXY-0005Bm-5B for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Apr 2014 19:43:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZqXD-00054V-5m for help-gnu-emacs@gnu.org; Mon, 14 Apr 2014 19:43:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZqX7-0003Cy-Nk for help-gnu-emacs@gnu.org; Mon, 14 Apr 2014 19:43:31 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:41453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZqX7-0003Cn-HW for help-gnu-emacs@gnu.org; Mon, 14 Apr 2014 19:43:25 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WZqX5-0005Dn-AZ for help-gnu-emacs@gnu.org; Tue, 15 Apr 2014 01:43:23 +0200 Original-Received: from 151.62.6.184 ([151.62.6.184]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Apr 2014 01:43:23 +0200 Original-Received: from lele by 151.62.6.184 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Apr 2014 01:43:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 151.62.6.184 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) Cancel-Lock: sha1:Xd/SX+J8l3j1bZ/V9J6HNLE0dAg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97133 Archived-At: Hi all, while I'm almost satisfied by my current implementation[#] of the solution to the problem of editing a HTML template embedded in Javascript code, when I compile it I get: In eet/edit: esk/js.el:154:32:Warning: assignment to free variable `eet/original-buffer' esk/js.el:155:52:Warning: assignment to free variable `eet/original-start' esk/js.el:156:50:Warning: assignment to free variable `eet/original-end' esk/js.el:157:51:Warning: assignment to free variable `eet/original-line' esk/js.el:158:32:Warning: assignment to free variable `eet/original-winconf' In eet/abort: esk/js.el:192:18:Warning: reference to free variable `eet/original-winconf' esk/js.el:193:26:Warning: reference to free variable `eet/original-buffer' esk/js.el:194:24:Warning: reference to free variable `eet/original-line' In eet/edit, I used the following code to store some information I need into buffer's local variables: (defun eet/edit (start end current-line) "Extract the template from the array of strings into a new buffer." (let ((template (buffer-substring-no-properties start end)) (original-buffer (current-buffer)) (winconf (current-window-configuration))) (switch-to-buffer (generate-new-buffer "*template-edit*")) (delete-other-windows-internal) (insert template) (eet/implode) (set-buffer-modified-p nil) (goto-char (point-min)) (when (looking-at "<") (html-mode)) (eet/mode 1) (set (make-local-variable 'eet/original-buffer) original-buffer) (set (make-local-variable 'eet/original-start) start) (set (make-local-variable 'eet/original-end) end) (set (make-local-variable 'eet/original-line) current-line) (set (make-local-variable 'eet/original-winconf) winconf) (message "Type C-c C-c to confirm changes, C-c C-k to abort"))) while eet/abort uses some of those to restore the original state: (defun eet/abort () "Used in template-edit-mode to close the popup window." (interactive) (let ((winconf eet/original-winconf) (original-buffer eet/original-buffer) (original-line eet/original-line)) (kill-buffer) (set-window-configuration winconf) (switch-to-buffer original-buffer) (goto-char (point-min)) (forward-line original-line))) Should I worry about the warnings? Am I doing it wrongly in some way? Is there a better approach to store that info that would keep the compiler happy? Thanks in advance for any hints, ciao, lele. [#] see http://hub.darcs.net/lelit/emacs-starter-kit/browse/esk/js.el#70 -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.