From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: add-hook and lambda functions Date: Fri, 30 Mar 2007 22:33:10 +0200 Message-ID: <87bqiampyx.fsf@ambire.localdomain> References: <460D7012.6010608@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1175310156 4503 80.91.229.12 (31 Mar 2007 03:02:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 31 Mar 2007 03:02:36 +0000 (UTC) Cc: Emacs Devel To: "Lennart Borgman \(gmail\)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 30 22:33:27 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HXNmm-0002PD-Em for ged-emacs-devel@m.gmane.org; Fri, 30 Mar 2007 22:33:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HXNpV-0000g2-AX for ged-emacs-devel@m.gmane.org; Fri, 30 Mar 2007 15:36:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HXNpS-0000fZ-0w for emacs-devel@gnu.org; Fri, 30 Mar 2007 16:36:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HXNpQ-0000fL-Hr for emacs-devel@gnu.org; Fri, 30 Mar 2007 16:36:09 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HXNpQ-0000fI-D7 for emacs-devel@gnu.org; Fri, 30 Mar 2007 15:36:08 -0500 Original-Received: from smtp-out3.libero.it ([212.52.84.43]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HXNmg-0008UJ-Eu for emacs-devel@gnu.org; Fri, 30 Mar 2007 16:33:18 -0400 Original-Received: from localhost (172.31.0.54) by smtp-out3.libero.it (7.3.120) id 45D9985C02B7E8FF; Fri, 30 Mar 2007 22:33:17 +0200 X-Scanned: with antispam and antivirus automated system at libero.it Original-Received: from smtp-out1.libero.it ([172.31.0.37]) by localhost (asav-out12.libero.it [192.168.32.40]) (amavisd-new, port 10024) with ESMTP id 52JkyXDm1ehx; Fri, 30 Mar 2007 22:33:17 +0200 (CEST) Original-Received: from ambire.localdomain (151.21.32.188) by smtp-out1.libero.it (7.3.120) id 45D5B264039C3EA9; Fri, 30 Mar 2007 22:33:17 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.50) id 1HXNma-0006Z7-Rz; Fri, 30 Mar 2007 22:33:12 +0200 In-Reply-To: <460D7012.6010608@gmail.com> (Lennart Borgman's message of "Fri\, 30 Mar 2007 22\:16\:18 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux) X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68811 () "Lennart Borgman (gmail)" () Fri, 30 Mar 2007 22:16:18 +0200 In hs-minor-mode a lambda function is added to the hook: (add-hook 'change-major-mode-hook (lambda () (hs-minor-mode -1)) nil t) Using a lambda function makes it a bit cumbersome to remove this hook if you want to. I would therefor prefer if named functions where used instead. Could this please be changed? it's a pretty common idiom. quick grep of "mode -1" shows several dozen hits. for example, in image-mode.el: (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) if you want to codify the idiom and convert applicable calls (including hideshow) to use the new code, that would be a good thing to do (after the release, probably). perhaps i am ignorant; does such an abstraction already exist? thi