From: Lele Gaifax <lele@metapensiero.it>
To: help-gnu-emacs@gnu.org
Subject: How can avoid "assignment to free variable" warning?
Date: Tue, 15 Apr 2014 01:43:09 +0200 [thread overview]
Message-ID: <87tx9vlboy.fsf_-_@nautilus.nautilus> (raw)
In-Reply-To: 87mwfqjfri.fsf@nautilus.nautilus
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.
next prev parent reply other threads:[~2014-04-14 23:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.3359.1380840943.10748.help-gnu-emacs@gnu.org>
2013-10-04 21:55 ` Easier way to edit a splitted long string Pascal J. Bourguignon
2014-04-12 23:21 ` Lele Gaifax
2014-04-14 23:43 ` Lele Gaifax [this message]
2014-04-14 23:50 ` How can avoid "assignment to free variable" warning? Stefan Monnier
2014-04-15 7:45 ` Lele Gaifax
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tx9vlboy.fsf_-_@nautilus.nautilus \
--to=lele@metapensiero.it \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).