Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help with flyspell-mode

11 views
Skip to first unread message

Daniel Dalton

unread,
Nov 21, 2009, 9:15:26 PM11/21/09
to help-gnu-emacs
Hi,

How can I enable flyspell-mode for documents that don't have an
extension?
eg. I've auto enabled it through .emacs for text, python, etc. Like
this:
emacs /tmp/stuff.txt
Loads flyspell-mode, but emacs /tmp/stuff wouldn't.

Anyone know how to enable flyspell mode for files with no extension?

Thanks

--
Cheers,
Dan

http://members.iinet.net.au/~ddalton/

signature.asc

Les Harris

unread,
Nov 21, 2009, 9:34:12 PM11/21/09
to

Daniel Dalton <d.da...@iinet.net.au> writes:
> Anyone know how to enable flyspell mode for files with no extension?

Using a file local variable for the files with no extension would be one
option. ie, adding:

-*- mode: flyspell; -*-

to the top of your file would turn flyspell mode on. This is only
useful for files you visit often though.

Alternatively, you can add an element to magic-mode-alist which makes
emacs match a given regular expression or match function against the
file being opened and setting the given mode. This method is only
useful if you can predict in someway what might be in the extension-less
files.

Unfortunately, Fundamental mode doesn't run any hooks so that method
won't work.

So a couple of suboptimal ideas is all I can come up with. Would love
to hear of a more robust approach perhaps using 'file' and setting the
mode based off that some how.


--
Do they only stand
By ignorance, is that their happy state,
The proof of their obedience and their faith?

Bernardo

unread,
Nov 22, 2009, 12:06:31 AM11/22/09
to help-gnu-emacs
>
> How can I enable flyspell-mode for documents that don't have an
> extension?
> eg. I've auto enabled it through .emacs for text, python, etc. Like
> this:
> emacs /tmp/stuff.txt
> Loads flyspell-mode, but emacs /tmp/stuff wouldn't.
>
> Anyone know how to enable flyspell mode for files with no extension?
>
> Thanks
>


possibly by using local variables e.g. something like this within a file
# -*- eval: (flyspell-mode) -*-

see (info "(emacs) Choosing Modes")

Daniel Dalton

unread,
Nov 22, 2009, 6:05:40 AM11/22/09
to help-gn...@gnu.org
On Sat, Nov 21, 2009 at 06:34:12PM -0800, Les Harris wrote:
>
> Using a file local variable for the files with no extension would be one
> option. ie, adding:
>
> -*- mode: flyspell; -*-
>
> to the top of your file would turn flyspell mode on. This is only
> useful for files you visit often though.
>
> Alternatively, you can add an element to magic-mode-alist which makes
> emacs match a given regular expression or match function against the
> file being opened and setting the given mode. This method is only

Yes, thanks I might have a play with this at some stage, but it is
probably easier if I just use the txt extention:)

Also, speaking of this can you show me the sintax of how I would
automatically set message-mode for a filename containing the words
"mutt-localhost"?

signature.asc

Colin S. Miller

unread,
Nov 22, 2009, 9:38:54 AM11/22/09
to
Les Harris wrote:
>
> Unfortunately, Fundamental mode doesn't run any hooks so that method
> won't work.
>

The OP might be able to add a defadvice to 'fundamental-mode.
The advice function could check the extension of the current buffer's
file, and run (flyspell-mode 't) if there isn't one.

HTH,
Colin S. Miller

--
Replace the obvious in my email address with the first three letters of the hostname to reply.

harven

unread,
Nov 22, 2009, 11:14:56 AM11/22/09
to
Daniel Dalton <d.da...@iinet.net.au> writes:

> Hi,
>
> How can I enable flyspell-mode for documents that don't have an
> extension?
> eg. I've auto enabled it through .emacs for text, python, etc. Like
> this:
> emacs /tmp/stuff.txt
> Loads flyspell-mode, but emacs /tmp/stuff wouldn't.
>
> Anyone know how to enable flyspell mode for files with no extension?

If you want to have flyspell mode enabled for all files, you may
want to try the find-file-hook.

(add-hook 'find-file-hook 'turn-on-flyspell)


Kevin Rodgers

unread,
Nov 26, 2009, 2:54:20 AM11/26/09
to help-gn...@gnu.org
Colin S. Miller wrote:
> Les Harris wrote:
>>
>> Unfortunately, Fundamental mode doesn't run any hooks so that method
>> won't work.
>>
>
> The OP might be able to add a defadvice to 'fundamental-mode.
> The advice function could check the extension of the current buffer's
> file, and run (flyspell-mode 't) if there isn't one.

Or:

(add-hook 'fundamental-mode 'turn-on-flyspell)

--
Kevin Rodgers
Denver, Colorado, USA

Lennart Borgman

unread,
Nov 26, 2009, 6:27:39 AM11/26/09
to Kevin Rodgers, help-gn...@gnu.org
On Thu, Nov 26, 2009 at 8:54 AM, Kevin Rodgers
<kevin.d...@gmail.com> wrote:

> Colin S. Miller wrote:
>>
>> Les Harris wrote:
>>>
>>> Unfortunately, Fundamental mode doesn't run any hooks so that method
>>> won't work.
>>>
>>
>> The OP might be able to add a defadvice to 'fundamental-mode.
>> The advice function could check the extension of the current buffer's
>> file, and run (flyspell-mode 't) if there isn't one.
>
> Or:
>
> (add-hook 'fundamental-mode 'turn-on-flyspell)


That will not work.


Stefan Monnier

unread,
Nov 27, 2009, 10:09:13 PM11/27/09
to
> Unfortunately, Fundamental mode doesn't run any hooks so that method

It does. It runs after-change-major-mode-hook.
Of course, some buffers are put in fundamental-mode by default without
ever actually calling fundamental-mode.


Stefan

0 new messages