help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Automatic flyspell


From: Robert Thorpe
Subject: Re: Automatic flyspell
Date: Mon, 23 Feb 2015 03:46:14 +0000

Haines Brown <address@hidden> writes:

> Emanuel Berg <address@hidden> writes:
...
>> If so, try this:
>>
>>     (set-default 'major-mode 'text-mode)
>
> Emanuel, thanks. I actually have Flyspell working in Fundamental mode
> with these lines:
>
>   (defun turn-on-flyspell () (flyspell-mode 1))
>   (add-hook 'find-file-hooks 'turn-on-flyspell)

In Emacs all modes are derived from fundamental-mode.  From there the
modes are divided into two great kingdoms, text-modes and prog-modes.
As you've found these need to be treated differently for the purposes of
flyspell.  Programming languages contain things that are considered
spelling errors in normal languages.

The best solution is to use hooks as Emanuel suggested:
(add-hook 'text-mode-hook 'turn-on-flyspell-prog)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)

I'd advise not using fundamental-mode at all.  There are few differences
between it and text-mode and in most cases text-mode's default behaviour
is more useful.

In general it's not a good idea to use find-file-hooks for something
like this.  What happens if you create an empty buffer and then change
the major mode later?  In that case flyspell won't be turned on.

BR,
Robert Thorpe



reply via email to

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