From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jun Newsgroups: gmane.emacs.help Subject: Re: How to get hook var of the current major mode? Date: Sun, 19 May 2013 09:52:53 +0000 Message-ID: <5198A0F5.8030704@gmail.com> References: <51974E79.1000406@gmail.com> <87r4h45rxz.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1368928392 15444 80.91.229.3 (19 May 2013 01:53:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 May 2013 01:53:12 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Dmitry Gutov Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 19 03:53:11 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 1UdsoA-0004lo-Ia for geh-help-gnu-emacs@m.gmane.org; Sun, 19 May 2013 03:53:10 +0200 Original-Received: from localhost ([::1]:48221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udso9-0002Nl-O2 for geh-help-gnu-emacs@m.gmane.org; Sat, 18 May 2013 21:53:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udsnw-0002NU-5Z for help-gnu-emacs@gnu.org; Sat, 18 May 2013 21:52:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Udsnv-0001gS-Ak for help-gnu-emacs@gnu.org; Sat, 18 May 2013 21:52:56 -0400 Original-Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]:45863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Udsnv-0001gJ-4O for help-gnu-emacs@gnu.org; Sat, 18 May 2013 21:52:55 -0400 Original-Received: by mail-pb0-f47.google.com with SMTP id rr4so4368965pbb.20 for ; Sat, 18 May 2013 18:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=AG8vtAkj/KTyteTzTzqaiZsAea3DqCdwrpLznQSln8I=; b=ACc8QTuPQJgLXJH6CdF5IoMuCJCic4LbVNY2QWHf+MpO8NQPaCXtiKg8bfQofI22VA LGX8hbZZ7RjbZ1JmUFui0b/GhAlO4IeZQcc0cd9Ag1WqyknqBuENWniPaIm9icJrESyx 7osAjNeu4C4qilOk++iQlmQZKH/dquZ96Lduq5U4AT0NDI44VFtZqOv1gifSJ6ZnW/XE OpSnTq6HiAWtoB0A6dSyys3sK99hnU/5Brkw9S831Oe6F3fnyz3h4Vio/O1CthGU7x6d xorPzSWnE0B3XkLmIjWiXjBKeJymcYNC3HosL6G6BBRvidXZZHOJ9tZW8t0ihc9iJ+fN FWgQ== X-Received: by 10.66.250.164 with SMTP id zd4mr33514787pac.141.1368928373633; Sat, 18 May 2013 18:52:53 -0700 (PDT) Original-Received: from [192.168.33.71] ([218.28.136.10]) by mx.google.com with ESMTPSA id zs12sm8392565pab.0.2013.05.18.18.52.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 18 May 2013 18:52:52 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <87r4h45rxz.fsf@yandex.ru> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::22f 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:90915 Archived-At: On 05/18/2013 01:38 PM, Dmitry Gutov wrote: > "netjunegg2@gmail.com" writes: > >> I want to do somthing like this: >> (let ((hook (get--the--current--major--mode--hook))) >> (add-hook hook (lambda () >> (setq truncate-lines t)))) > If the major mode is already current, then the hook has already run, > hasn't it? Adding a lambda to it will have to effect on the next buffer > in the same mode. And if the above form is run many times, each time a > new lambda will be added to the hook. > > But anyway, try (intern (format "%s-hook" major-mode)). > . > This is what I want. In fact, I have defined a function which turns on yasnippet minor mode, auto complete mode, etc, and a macro which can run some code for all buffers in the same mode as the current. I want to turn on some modes only when editing source code, not when viewing, and not for buffers other than source code, which is not too usefull for chinese. Thank you.