From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: How to set up a minor mode depending on a major mode? Date: Tue, 12 May 2009 08:43:18 +0200 Message-ID: <87skjastx5.fsf@thinkpad.tsdh.de> References: <20090511114317.GA12496@tomas> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1242110659 8274 80.91.229.12 (12 May 2009 06:44:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 May 2009 06:44:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 12 08:44:11 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 1M3lik-0003ab-1M for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 08:44:10 +0200 Original-Received: from localhost ([127.0.0.1]:46101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3lij-0001Bb-Ir for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 02:44:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3liM-0001AH-1x for help-gnu-emacs@gnu.org; Tue, 12 May 2009 02:43:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3liI-00017A-1e for help-gnu-emacs@gnu.org; Tue, 12 May 2009 02:43:45 -0400 Original-Received: from [199.232.76.173] (port=36749 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3liH-000177-Pz for help-gnu-emacs@gnu.org; Tue, 12 May 2009 02:43:41 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:54283 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M3liH-0005Fw-3i for help-gnu-emacs@gnu.org; Tue, 12 May 2009 02:43:41 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1M3li7-00070W-CI for help-gnu-emacs@gnu.org; Tue, 12 May 2009 06:43:31 +0000 Original-Received: from dhcp42.uni-koblenz.de ([141.26.71.42]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 May 2009 06:43:31 +0000 Original-Received: from tassilo by dhcp42.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 May 2009 06:43:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dhcp42.uni-koblenz.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux) Cancel-Lock: sha1:XWGXx3cBzlrQLVOQyqv8pBJsB7g= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:64358 Archived-At: Lennart Borgman writes: Hi! >> 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: >> >>    (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. Just a blind guess: Maybe the argument t is not sufficient to turn on v-l-m. In general, minor modes are enabled if the function is given a positive argument, and they're disabled if the argument is negative. Try (add-hook 'am-mode-hook '(lambda () (visual-line-mode 1))) or even better (add-hook 'am-mode-hook 'turn-on-visual-line-mode) Bye, Tassilo -- Richard Stallman can touch MC Hammer