[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: auto-mode-alist, adding two modes

From: Joost Kremers
Subject: Re: auto-mode-alist, adding two modes
Date: 8 Oct 2007 16:01:30 GMT
User-agent: slrn/ (Linux)

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

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

(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]



[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                                      address@hidden
Selbst in die Unterwelt dringt durch Spalten Licht

reply via email to

[Prev in Thread] Current Thread [Next in Thread]