From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: interactive closure — variables not bound
Date: Wed, 28 Sep 2016 08:41:50 -0400 [thread overview]
Message-ID: <jwvoa38cibj.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 87y42ch7e1.fsf@elephly.net
> The problem with this definition is that it doesn’t work (the other
> problem is that I’m replacing one ugly hack with another). At runtime
> Emacs says that “field-type” is undefined. At compile time Emacs says
> that in the callback “xww”, “field-value”, and “field-type” are
> references to free variables.
Indeed, currently, the `interactive' spec can't be re-created
individually for every closure. IOW the spec is built once and forall
for a given lambda expression and hence can't refer to surrounding
non-global variables.
I suggest you M-x report-emacs-bug.
This said, in your example, I don't see what benefit you expect to get
from writing
(call-interactively
(lambda (str)
(interactive
(list (cond ((equal "text" field-type)
(read-string "Text: " field-value))
((equal "password" field-type)
(read-passwd "Password: " nil field-value))
((equal "textarea" field-type)
(xwidget-webkit-begin-edit-textarea xww field-value)))))
(xwidget-webkit-execute-script
xww
(format "findactiveelement(document).value='%s'" str)))))))))
instead of
(let ((str (cond ((equal "text" field-type)
(read-string "Text: " field-value))
((equal "password" field-type)
(read-passwd "Password: " nil field-value))
((equal "textarea" field-type)
(xwidget-webkit-begin-edit-textarea xww field-value)))))
(xwidget-webkit-execute-script
xww
(format "findactiveelement(document).value='%s'" str)))))))))
[ Oh, and while I'm here, let me advertize pcase:
(let ((str (pcase field-type
("text" (read-string "Text: " field-value))
("password" (read-passwd "Password: " nil field-value))
("textarea" ...
]
Stefan
next prev parent reply other threads:[~2016-09-28 12:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 6:21 interactive closure — variables not bound Ricardo Wurmus
2016-09-28 12:41 ` Stefan Monnier [this message]
2016-09-28 21:12 ` Ricardo Wurmus
2016-09-29 0:07 ` Stefan Monnier
2016-09-29 9:09 ` Ricardo Wurmus
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvoa38cibj.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.