From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.help Subject: Re: How to set up a minor mode depending on a major mode? Date: Tue, 12 May 2009 00:13:54 +0200 Message-ID: References: <20090511114317.GA12496@tomas> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1242080079 9544 80.91.229.12 (11 May 2009 22:14:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 May 2009 22:14:39 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 12 00:14:29 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M3dlS-0006XI-4Y for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 00:14:26 +0200 Original-Received: from localhost ([127.0.0.1]:45107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3dlR-00023u-Gw for geh-help-gnu-emacs@m.gmane.org; Mon, 11 May 2009 18:14:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3dl5-00023p-SO for help-gnu-emacs@gnu.org; Mon, 11 May 2009 18:14:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3dl1-00023D-7z for help-gnu-emacs@gnu.org; Mon, 11 May 2009 18:14:03 -0400 Original-Received: from [199.232.76.173] (port=46227 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3dl1-00023A-4L for help-gnu-emacs@gnu.org; Mon, 11 May 2009 18:13:59 -0400 Original-Received: from mail-bw0-f161.google.com ([209.85.218.161]:38611) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M3dl0-0002Jb-ST for help-gnu-emacs@gnu.org; Mon, 11 May 2009 18:13:59 -0400 Original-Received: by bwz5 with SMTP id 5so3071980bwz.42 for ; Mon, 11 May 2009 15:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=MEPG0OlngFd/BAKHEhlkqgpP0U9+NcMKbHKxvjSj2B4=; b=yHIxV8HhmbgPHnkJtxI+moUSoGpCQyDDJEYJiC6FhUnRNZu5av1oBNV+adymI0zErb ZgE70l7x2Ks3i62HOeGx3Kg+Bgy71k7WCIxL/BX9VWKQtWPzwCtvHJ4EozBr7reZKZiE d/tDk+lyR9VQfF5cZ+iYPIff+WZKK2NwUp1pY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=knQN7J2bsdvCMSl4LZCpTQ8wtFdTnNFHevWt9JKAkvDlskFuVysk2fcd2Lhg7HRrat V1cVST40Pw+WB/aJttbsJA0V+aVl+o81/6oxfzMxsjNQkrX4cQWh/UsixsoIopbT+GTU sBUPhKe3ixII3EgDy8N9YVOQMYbCZSU6n+454= Original-Received: by 10.223.104.74 with SMTP id n10mr4296717fao.5.1242080034943; Mon, 11 May 2009 15:13:54 -0700 (PDT) In-Reply-To: <20090511114317.GA12496@tomas> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64353 Archived-At: On Mon, May 11, 2009 at 1:43 PM, wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, Emacs-folks > > I'd like to set up some minor mode whenever a major mode is switched on. > I gather that the recommended method seems to be to hook into the major > mode hook like so: > > =C2=A0 =C2=A0(add-hook 'am-mode-hook '(lambda () (visual-line-mode t))) > > (i.e. switch visual-line-mode on whenever am-mode-hook is swiitched on). > > However, this doesn't work, and I have tracked it back to the standard > major-mode machinery doing a (kill-all-local-variables) sweeping away > whatever tidbits the minor mode needs to survive. Running the major mode hook should be the very last thing a major mode does. From your description it sounds like am-mode runs the hook earlier. That would be a bug.