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: interactive closure =?utf-8?Q?=E2=80=94?= variables not bound Date: Wed, 28 Sep 2016 08:41:50 -0400 Message-ID: References: <87y42ch7e1.fsf@elephly.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1475066592 14519 195.159.176.226 (28 Sep 2016 12:43:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Sep 2016 12:43:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 28 14:43:09 2016 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 1bpECQ-0002Bl-GS for ged-emacs-devel@m.gmane.org; Wed, 28 Sep 2016 14:42:58 +0200 Original-Received: from localhost ([::1]:58503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpECO-0007C5-Q9 for ged-emacs-devel@m.gmane.org; Wed, 28 Sep 2016 08:42:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpECE-0007AY-Qu for emacs-devel@gnu.org; Wed, 28 Sep 2016 08:42:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpECB-0008Fi-Fs for emacs-devel@gnu.org; Wed, 28 Sep 2016 08:42:46 -0400 Original-Received: from [195.159.176.226] (port=54076 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpECB-0008F6-99 for emacs-devel@gnu.org; Wed, 28 Sep 2016 08:42:43 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1bpEBo-0005lw-Eq for emacs-devel@gnu.org; Wed, 28 Sep 2016 14:42:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:zGBgW8yzrTvF5Z0Rnu6STVZSZVQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:207857 Archived-At: > 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