From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Zhongwei Yao Newsgroups: gmane.emacs.help Subject: Re: Problem when run-hook-with-args with closure Date: Mon, 22 Dec 2014 19:20:49 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1419247270 793 80.91.229.3 (22 Dec 2014 11:21:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Dec 2014 11:21:10 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 22 12:21:04 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 1Y312t-0005LY-PM for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Dec 2014 12:21:03 +0100 Original-Received: from localhost ([::1]:40085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y312s-0003aJ-Q5 for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Dec 2014 06:21:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y312i-0003aC-MY for help-gnu-emacs@gnu.org; Mon, 22 Dec 2014 06:20:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y312h-00022D-La for help-gnu-emacs@gnu.org; Mon, 22 Dec 2014 06:20:52 -0500 Original-Received: from mail-lb0-x229.google.com ([2a00:1450:4010:c04::229]:64465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y312h-00021G-EN for help-gnu-emacs@gnu.org; Mon, 22 Dec 2014 06:20:51 -0500 Original-Received: by mail-lb0-f169.google.com with SMTP id p9so3757130lbv.28 for ; Mon, 22 Dec 2014 03:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yDMn3kMIPPYyrSqvzyOTk2wEyg8MNOlBENZPl0A5QzU=; b=LUdEJsZO74L5INwhxTn6CMowADe31FrioZ9ILekM1VsWPg2H7tDZ2HsCFwR3v4MUCi I3LPDI6beV+V6jshtE+yvc8+s6QbHlur8xg8Im61dAlKxULMXNKMafMX9JIxhm7RAX1J jtFEHyxpUUpoKKwv3k988WdJKUo/azJMUKOHlxWnzjkfBPfExRs5CXxG0IFKSdrqHEnB u612dogS9/5iGmAC6UqLFqOiK1ODo4rkeLGCiRqT84AsVvOOk+9j9sJLAFF1WIjG+v8+ JbW7yi8oJ2EQZrcW498y7Am2HG55+rbPlFfFZyfNACUKIPBk0cmPx5LsMv2Qwlo0mgVk TWSQ== X-Received: by 10.152.3.195 with SMTP id e3mr21561667lae.8.1419247249802; Mon, 22 Dec 2014 03:20:49 -0800 (PST) Original-Received: by 10.114.59.80 with HTTP; Mon, 22 Dec 2014 03:20:49 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::229 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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:101698 Archived-At: Hi, Stefan, Thanks, it works! Best Regards, Zhongwei On Fri, Dec 19, 2014 at 10:11 PM, Stefan Monnier wrote: > > (setq foo > > (lambda (y) > > (message "x+y=%d" (+ x y))))) > > (run-hook-with-args 'foo 1) > > Hooks should contain *lists* of functions. The fact that they can also > just contain a function is an old backward compatibility hack: better > not rely on it. > > So, if you do it right, you won't hit the bug: > > (setq foo > (list (lambda (y) > (message "x+y=%d" (+ x y)))))) > (run-hook-with-args 'foo 1) > > Or better yet: > > (add-hook 'foo > (lambda (y) > (message "x+y=%d" (+ x y)))))) > (run-hook-with-args 'foo 1) > > > -- Stefan > > >