From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gijs Hillenius Newsgroups: gmane.emacs.help Subject: Re: auto-mode-alist, adding two modes Date: Mon, 08 Oct 2007 19:55:20 +0200 Message-ID: <87ejg57apj.fsf@hillenius.net> References: <878x6dboyn.fsf@hillenius.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1191871073 11209 80.91.229.12 (8 Oct 2007 19:17:53 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Oct 2007 19:17:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 08 21:17:51 2007 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 1Iey6h-0002qy-Ir for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Oct 2007 21:17:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iey6c-0005se-Bx for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Oct 2007 15:17:30 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Original-Newsgroups: gnu.emacs.help X-Operating-System: Debian GNU/Linux Sid X-GPGP-Fingerprint: 0D0B 9C67 0520 3B27 A91C 369B 7154 1B0A 04CF 3929 User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:RM2DTpfqvz0s0eMNOq+yB8WehHw= Original-Lines: 56 Original-NNTP-Posting-Host: 82.93.230.201 Original-X-Trace: 1191866121 news.xs4all.nl 237 [::ffff:82.93.230.201]:59152 Original-X-Complaints-To: abuse@xs4all.nl Original-Xref: shelby.stanford.edu gnu.emacs.help:152711 X-Mailman-Approved-At: Mon, 08 Oct 2007 15:17:14 -0400 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:48221 Archived-At: On 8 Oct 2007, Joost Kremers wrote: > Gijs Hillenius wrote: >> I would like to get emacs to use longlines-mode *and* flyspell-mode >> for all files ending in .txt >> >> If I add this in my .emacs >> >> (add-to-list 'auto-mode-alist '("\\.txt\\'" . longlines-mode )) >> >> followed by a similar line for flyspell, ignores the first, and uses >> only the latter. > you should read the documentation of auto-mode-alist. it says quite > clearly that it is a list for specifying *major* modes. both > > longline-mode and flyspell-mode are minor modes, and should > therefore be specified in a different way. > > not explicitly stated, but still deducible from the documentation is > the fact that only the *first* matching regexp in auto-mode-alist is > used. so once flyspell-mode has been found, the list is not searched > further anymore.[1] this makes sense, because a buffer can only have > one major mode. > > note that auto-mode-alist already specifies a major mode with files > ending in .txt, namely text-mode. your customisation therefore > disables text-mode for .txt files, which is probably not what you > want. > > to do what you want, you may add flyspell-mode and > longlines-mode to text-mode-hook: > > (add-hook 'text-mode-hook 'longlines-mode) > (add-hook 'text-mode-hook 'flyspell-mode) > > adding these two minor modes to text-mode-hook makes sure that they are > always turned on when text-mode is selected. > > see (info "(emacs)Hooks") for details on hooks.[2] Thanks for these speedy replies. I do *not* want to add both of these minor modes to text-mode, for this messes up other applications, such as my dear gnus. So, I settled on (add-to-list 'auto-mode-alist '("\\.txt\\'" . longlines-mode )) (add-hook 'longlines-mode-hook 'flyspell-mode) The latter of which, if I understand it correctly, adds a fly-spell wherever I have longlines-mode. Which is something I can live with, for now. Gijs