From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: How to get hook var of the current major mode? Date: Sun, 19 May 2013 00:38:59 +0400 Message-ID: <874ne0owf0.fsf@yandex.ru> References: <51974E79.1000406@gmail.com> <878v3cm5s1.fsf@VLAN-3434.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1368909561 30977 80.91.229.3 (18 May 2013 20:39:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 May 2013 20:39:21 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 18 22:39:19 2013 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 1UdnuQ-0008Th-NS for geh-help-gnu-emacs@m.gmane.org; Sat, 18 May 2013 22:39:18 +0200 Original-Received: from localhost ([::1]:50566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdnuQ-0006zG-7u for geh-help-gnu-emacs@m.gmane.org; Sat, 18 May 2013 16:39:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdnuC-0006yv-7D for help-gnu-emacs@gnu.org; Sat, 18 May 2013 16:39:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Udnu7-0003nI-PZ for help-gnu-emacs@gnu.org; Sat, 18 May 2013 16:39:04 -0400 Original-Received: from mail-lb0-f173.google.com ([209.85.217.173]:42126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udnu7-0003n3-I9 for help-gnu-emacs@gnu.org; Sat, 18 May 2013 16:38:59 -0400 Original-Received: by mail-lb0-f173.google.com with SMTP id t10so5393110lbi.4 for ; Sat, 18 May 2013 13:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-antivirus :x-antivirus-status; bh=HKrSSBGafbyUFqikIEhJaUd2G0iMSYruCGWaw5yutyM=; b=E1xGTZDltNhOKmrIAmCYDQ+jVSa7crmolwmvz5jZVYB91B+IVAOoUEJTaJ6Yxh0hrQ r4TYJhicDspOqxW2wRFZPo4kD4ItW2/4i4xbrfkeDG0/1F6rv2Im19j9+Vjtqe6IbNfr pLIC4ie0I4LYYs1vk67NPHX9J4P+r9OinqmwnM/fRdGXHS3fAkEvisKYoBY4+1FouOGg xIfCyRO4LLaxvy9H2+gx6ObH1U/M4lE6eWFtICra6wfH14pFokUmuCbY642Tpgl9kEx1 epVnTQvr3FFJTwYLTWC225vWYZRMMY6fyK7MAPmXiLi8y4Z1XFG7siNvRJCLaQMBCSez ATMg== X-Received: by 10.152.30.103 with SMTP id r7mr3703359lah.25.1368909537886; Sat, 18 May 2013 13:38:57 -0700 (PDT) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id y1sm7190842lay.3.2013.05.18.13.38.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 18 May 2013 13:38:57 -0700 (PDT) In-Reply-To: <878v3cm5s1.fsf@VLAN-3434.student.uu.se> (Emanuel Berg's message of "Sat, 18 May 2013 21:45:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Antivirus: avast! (VPS 130518-0, 18.05.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.173 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:90912 Archived-At: Emanuel Berg writes: > Dmitry Gutov writes: > >>> I want to do somthing like this: >>> (let ((hook (get--the--current--major--mode--hook))) >>> (add-hook hook (lambda () >>> (setq truncate-lines t)))) >> >> ...And if the above form is run many times, each time a new lambda >> will be added to the hook. > > When the hook fires, are all those lambda executed (doing the same > thing)? Actually, sorry, I take that back. Even in lexical-binding environment, (lambda () (abc)) is `equal' to another (lambda () (abc)), at least currently. And `add-hook' checks if the given function is already present in the list, with `member'. So there won't be duplicates in the hook value. Still, like I wrote previously, adding function to the hook of the current major mode doesn't make much sense.