all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gijs Hillenius <gijs-nopsam-@hillenius.net>
To: help-gnu-emacs@gnu.org
Subject: Re: auto-mode-alist, adding two modes
Date: Mon, 08 Oct 2007 19:55:20 +0200	[thread overview]
Message-ID: <87ejg57apj.fsf@hillenius.net> (raw)
In-Reply-To: slrnfgkl1e.2ps.joostkremers@j.kremers4.news.arnhem.chello.nl

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

  reply	other threads:[~2007-10-08 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-08 15:33 auto-mode-alist, adding two modes Gijs Hillenius
2007-10-08 15:37 ` weber
2007-10-08 16:01 ` Joost Kremers
2007-10-08 17:55   ` Gijs Hillenius [this message]
2007-10-08 18:20     ` Joost Kremers
2007-10-09  2:22   ` Barry Margolin
2007-10-09 11:01     ` Joost Kremers
2007-10-09 21:34 ` Edward O'Connor
     [not found] ` <mailman.1891.1191965685.18990.help-gnu-emacs@gnu.org>
2007-10-10 23:47   ` Johan Bockgård
2007-10-12  5:37     ` Gijs Hillenius

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ejg57apj.fsf@hillenius.net \
    --to=gijs-nopsam-@hillenius.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.