From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?I=C3=B1igo?= Serna Newsgroups: gmane.emacs.help Subject: Re: How to use a variable from outer scope in the success function of a request call? Date: Sat, 29 Aug 2015 11:11:01 +0200 Message-ID: <87oahqe9y2.fsf@inigo.katxi.org> References: <877foezg4h.fsf@kuiper.lan.informatimago.com> <87pp26ebn1.fsf@inigo.katxi.org> 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 1440839489 3319 80.91.229.3 (29 Aug 2015 09:11:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2015 09:11:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 29 11:11:21 2015 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 1ZVcAS-00029l-Gh for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Aug 2015 11:11:20 +0200 Original-Received: from localhost ([::1]:51650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVcAR-00040t-KE for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Aug 2015 05:11:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVcAG-00040m-0W for help-gnu-emacs@gnu.org; Sat, 29 Aug 2015 05:11:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVcAC-0005nW-Qk for help-gnu-emacs@gnu.org; Sat, 29 Aug 2015 05:11:07 -0400 Original-Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:33758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVcAC-0005nI-IQ for help-gnu-emacs@gnu.org; Sat, 29 Aug 2015 05:11:04 -0400 Original-Received: by wicne3 with SMTP id ne3so4699036wic.0 for ; Sat, 29 Aug 2015 02:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:to:subject:in-reply-to:date:message-id:mime-version :content-type:content-transfer-encoding; bh=A6sq4csQbMhj0ZDm6ALTHHIHNjzV+wFelmm+Hw64Kyw=; b=EwJxIjFeZcXH7MJu1y2aHYsiMIBRho012bAvk6UFJAF6ZpZVQxPOJMZmgpXOEWSgXh LstPc/z0Ll3fs7FJbFzYl1PVttBTXTeCHBzWa6iJDoeNWBz7XKXjqo5d50zSEDaeBJln S/kgLVi4TgtMAeiIwtWIpol55wKblIGNhrfOUoK77kIRVICLnyfGJJSlmxGnhfrb9/2e klzSRDMzRoLVLNjvH2ZPAYmwAvX4Ly+fogd/8kc0ehTPCGDEe9eHSVtyR66QFI17hTRo o0mN17qIzD3BWu3JltJYdEH5vRlnQ2oR0Ipf2HRkzIaMhWWs2ZvOVdVk5C7MN539Gdec Hnqg== X-Received: by 10.194.121.131 with SMTP id lk3mr15209403wjb.77.1440839463847; Sat, 29 Aug 2015 02:11:03 -0700 (PDT) Original-Received: from inigo.katxi.org (62.57.74.108.dyn.user.ono.com. [62.57.74.108]) by smtp.gmail.com with ESMTPSA id y13sm11891494wjq.26.2015.08.29.02.11.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Aug 2015 02:11:02 -0700 (PDT) In-reply-to: <87pp26ebn1.fsf@inigo.katxi.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d 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:106918 Archived-At: Answering myself... Iñigo Serna writes: > And to learn more myself, do you have any hint why `fn3' or `fn4' don't work and how to make > it work? Using `lexical-let' with a dummy variable works: (setq lexical-binding t) (defun fn4 (c2) (lexical-let ((c c2)) (my-request2 "https://api.stackexchange.com/2.1/questions" #'(lambda (data &optional d) (let* ((item (elt (assoc-default 'items data) 0)) (title (assoc-default 'title item)) (tags (assoc-default 'tags item))) (message "PARAMS: %S" d) (message "=> %s %S" title tags) (message "LAST: %S" (nth 2 d)))) (list "OOOO" "AAAA" c)))) (fn4 "TEXT") Btw, any solution to mark that c2 function parameter as "lexical" to avoid using the intermediate variable and 'lexical-let' ? This link has been of much help to understand what happened, specially the "Another example which shows the difference" section: http://emacswiki.org/emacs/DynamicBindingVsLexicalBinding Thanks for all the help, Iñigo Serna