From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: auto-mode-alist, adding two modes Date: 8 Oct 2007 16:01:30 GMT Message-ID: References: <878x6dboyn.fsf@hillenius.net> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1191861655 7171 80.91.229.12 (8 Oct 2007 16:40:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Oct 2007 16:40:55 +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 18:40:53 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 1Ieves-0007Fk-NS for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Oct 2007 18:40:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ieven-0001gD-9x for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Oct 2007 12:40:37 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-X-Trace: individual.net cJlx6RUFDLlJX53qp2DpVwefPyXMvQiNoaUeHQQPEfI4MnVQ/w Cancel-Lock: sha1:X9AkLpZfk3rdlRzaSVA13xVp5Ys= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/0.9.8.1 (Linux) Original-Xref: shelby.stanford.edu gnu.emacs.help:152706 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:48213 Archived-At: 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] HTH joost Footnotes: [1] note that add-to-list normally adds items to the front of a list, so that flyspell-mode is indeed the first match found. [2] or type: C-h i m emacs RET m hooks RET -- Joost Kremers joostkremers@yahoo.com Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)