all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Automatic flyspell
@ 2015-02-20 16:46 Haines Brown
  2015-02-21 23:38 ` Emanuel Berg
  2015-02-22  0:48 ` Emanuel Berg
  0 siblings, 2 replies; 9+ messages in thread
From: Haines Brown @ 2015-02-20 16:46 UTC (permalink / raw)
  To: help-gnu-emacs

In exploring how to get flyspell enabled for all text files, I get
impression these should work, but despite them I remain in the
Fundamental mode with the only minor mode being Fill.

(dolist (hook '(Lispt-mode-hook ...))
      (add-hook hook #'flyspell-mode))

(add-hook 'text-mode-hook 'flyspell-mode)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-20 16:46 Automatic flyspell Haines Brown
@ 2015-02-21 23:38 ` Emanuel Berg
  2015-02-22  0:48 ` Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-02-21 23:38 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@engels.histomat.net> writes:

> In exploring how to get flyspell enabled for all
> text files, I get impression these should work, but
> despite them I remain in the Fundamental mode with
> the only minor mode being Fill. ...

I have this: 

    (setq text-mode-hook (lambda () (auto-fill-mode) (abbrev-mode)))

Try add `flyspell-mode' to the list. And remove the
stuff you don't like...

But it won't work in fundamental mode, of course. In
text mode, it should work, and when you get that to
work it should be the same principle with any other
mode in which you might (?) want to enable flyspell.

-- 
underground experts united


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-20 16:46 Automatic flyspell Haines Brown
  2015-02-21 23:38 ` Emanuel Berg
@ 2015-02-22  0:48 ` Emanuel Berg
  2015-02-22  9:46   ` Haines Brown
  1 sibling, 1 reply; 9+ messages in thread
From: Emanuel Berg @ 2015-02-22  0:48 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@engels.histomat.net> writes:

> In exploring how to get flyspell enabled for all
> text files, I get impression these should work, but
> despite them I remain in the Fundamental mode with
> the only minor mode being Fill.

Aha, now I think I understand. Do you want to use
text-mode for files like README but you end up in
fundamental-mode?

If so, try this:

    (set-default 'major-mode 'text-mode)

-- 
underground experts united


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-22  0:48 ` Emanuel Berg
@ 2015-02-22  9:46   ` Haines Brown
  2015-02-22 23:24     ` Emanuel Berg
  2015-02-23  3:46     ` Robert Thorpe
  0 siblings, 2 replies; 9+ messages in thread
From: Haines Brown @ 2015-02-22  9:46 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Haines Brown <haines@engels.histomat.net> writes:
>
>> In exploring how to get flyspell enabled for all
>> text files, I get impression these should work, but
>> despite them I remain in the Fundamental mode with
>> the only minor mode being Fill.
>
> Aha, now I think I understand. Do you want to use
> text-mode for files like README but you end up in
> fundamental-mode?
>
> 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)

For example it is on now as I write, and my present modes are Message
Fly MML Abbrev Fill Narrow. This probably because I started gnus in
emacs with the two lines above in its init file. When I start emacs its
modes are Lisp Interaction Fill. When I then open a text file with it,
the modes change to Fundamental Fly Fill. So it seems that flyspell is
working in Fundamental mode. If I give a test text file an .txt
extension, emacs opens in the Text Fly Fill modes.

I see no difference off hand from when I open that file without the
extension in the Fundamental Fly Fill modes or with it in the Text
mode. This raises a question, why should I set default to Text mode?

All my work is done in LaTeX mode rather than use a word processor (I
used to use WordPerfect under DOS, but have little idea how to use these
GUI things---too complicated for my antiquated brain). However, for
LaTeX emacs uses a different init file with the lines:

  (defun turn-on-flyspell () (flyspell-mode 1))
  (add-hook 'find-file-hooks 'turn-on-flyspell)

When the emacs session I initially mentioned opens a .tex file, it opens
in the LaTeX Fly Fill modes and knows not to mark commands or
environments such as \subsection{} as misspellings.

When I open a .java file I'm in the Java/1 Fly Abbrev Fill modes. When I
open a .c file, I'm in the C/1 Fly Abbrev Fill modes. In these cases
commands are marked as misspellings. If I did any serious programming
I'd have to tailor Flyspell for those modes.

Haines


 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-22  9:46   ` Haines Brown
@ 2015-02-22 23:24     ` Emanuel Berg
  2015-02-23  3:46     ` Robert Thorpe
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-02-22 23:24 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@engels.histomat.net> writes:

> I see no difference off hand from when I open that
> file without the extension in the Fundamental Fly
> Fill modes or with it in the Text mode. This raises
> a question, why should I set default to Text mode?

If you don't want it as the default mode, you
shouldn't, of course. But now I don't understand your
problem anymore (if I ever did).

> However, for LaTeX emacs uses a different init file
> with the lines:
>
>   (defun turn-on-flyspell () (flyspell-mode 1))
> (add-hook 'find-file-hooks 'turn-on-flyspell)

That doesn't seem to carry anything LaTeX specific,
which would look along the lines of:

(setq latex-mode-hook (lambda ()
                         (flyspell-mode 1)
                         ; other modes and options
                         ))

> When the emacs session I initially mentioned opens a
> .tex file, it opens in the LaTeX Fly Fill modes and
> knows not to mark commands or environments such as
> \subsection{} as misspellings.

OK? I never did Fly in LaTeX, but I did do `ispell-buffer'
and that catches most text areas. Sometimes there can
be problems in certain constructs, e.g.:

    \def\hierarchicalscheduler{A hierarchical
      scheduler is a scheduler that consists of
      several schedulers that are organized
      hierarchically, in a tree structure. ... }

Perhaps because of the braces `ispell-buffer' doesn't
catch mistakes in between, so I use `ispell-region'
for those.

But for common usage, including
\subsection{sphelling}, it works fine.

> When I open a .java file I'm in the Java/1 Fly
> Abbrev Fill modes. When I open a .c file, I'm in the
> C/1 Fly Abbrev Fill modes. In these cases commands
> are marked as misspellings. If I did any serious
> programming I'd have to tailor Flyspell for those
> modes.

Serious programming is typically not about spelling :)
If you have tons of text in your programs, consider
moving them to textfiles and the like (perhaps XML if
it involves advanced interaction, e.g. a RPG with
dialog trees etc.). For but a few error messages and
the like in a C program you might be helped by
`ispell-comments-and-strings'.

And for Gnus messages: `ispell-message'. None of this
is on the Fly but I thought I'd mention it. Check out
some more work on this:

    http://user.it.uu.se/~embe8573/conf/emacs-init/spell.el

-- 
underground experts united


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-22  9:46   ` Haines Brown
  2015-02-22 23:24     ` Emanuel Berg
@ 2015-02-23  3:46     ` Robert Thorpe
  1 sibling, 0 replies; 9+ messages in thread
From: Robert Thorpe @ 2015-02-23  3:46 UTC (permalink / raw)
  To: Haines Brown; +Cc: help-gnu-emacs

Haines Brown <haines@engels.histomat.net> writes:

> Emanuel Berg <embe8573@student.uu.se> 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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
       [not found] <mailman.664.1424663182.31049.help-gnu-emacs@gnu.org>
@ 2015-02-23 19:19 ` Emanuel Berg
  2015-02-23 21:05   ` Robert Thorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Emanuel Berg @ 2015-02-23 19:19 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe <rt@robertthorpeconsulting.com> writes:

> 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)

Leaving aside the issue "should programming be
spelled?" there is also the natural way to do this on
a mode basis. Those hooks should be present already
for the popular modes and if they ain't they should be
sooner rather than later anyway so might just put them
there already. Just fill them in as you go. It is much
easier to have success with that than to predict the
future and try to put something to work that will work
everywhere and forever ever since. Even if one
programs in some 20 modes which is remote that's only
some 20-40 lines to do this that look virtually the
same. (Compare, this paragraph is thirteen lines, and
they don't even look the same...)

-- 
underground experts united


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
  2015-02-23 19:19 ` Emanuel Berg
@ 2015-02-23 21:05   ` Robert Thorpe
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Thorpe @ 2015-02-23 21:05 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Robert Thorpe <rt@robertthorpeconsulting.com> writes:
>
>> 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)
>
> Leaving aside the issue "should programming be
> spelled?"

Flyspell-prog-mode is supposed to check only comments and strings.  I
tried it in C mode just before writing my previous post and it seemed to
only check the strings.

> there is also the natural way to do this on
> a mode basis.

I agree.  All of my own customizations are written that way.  I don't
touch the settings for a particular mode until I start using and find
out what I want to change.

In the post you quote though I was giving advice to someone who said
they wanted flyspell everywhere.

BR,
Robert Thorpe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Automatic flyspell
       [not found] <mailman.708.1424725551.31049.help-gnu-emacs@gnu.org>
@ 2015-02-25 17:01 ` Emanuel Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2015-02-25 17:01 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Thorpe <rt@robertthorpeconsulting.com> writes:

> Flyspell-prog-mode is supposed to check only
> comments and strings. I tried it in C mode just
> before writing my previous post and it seemed to
> only check the strings.

OK, I suspected that since there were two versions.
Yes, that's intelligent but perhaps a bit overkill. It
depends how many strings you have and how poor your
spelling is, I suppose. Unless it comes with a big
overhead it is nothing to worry about.

> In the post you quote though I was giving advice to
> someone who said they wanted flyspell everywhere.

Well, I just thought about it when I saw the
collective prog-mode-hook - you mean I should have
quoted it differently to make explicit the advice was
given to the OP and not you?

Yes, I think it is the right attitude to help people
even though you would have solved the problem in
another way (including degrading it from problem
status). That's what I try to do whenever I can but I
also don't have a problem adding a note what I think
on a larger scale. If I however only would give such
comments that would have been a bad attitude indeed.

-- 
underground experts united


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-25 17:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 16:46 Automatic flyspell Haines Brown
2015-02-21 23:38 ` Emanuel Berg
2015-02-22  0:48 ` Emanuel Berg
2015-02-22  9:46   ` Haines Brown
2015-02-22 23:24     ` Emanuel Berg
2015-02-23  3:46     ` Robert Thorpe
     [not found] <mailman.664.1424663182.31049.help-gnu-emacs@gnu.org>
2015-02-23 19:19 ` Emanuel Berg
2015-02-23 21:05   ` Robert Thorpe
     [not found] <mailman.708.1424725551.31049.help-gnu-emacs@gnu.org>
2015-02-25 17:01 ` Emanuel Berg

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.