questions/comments about the spell feature

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

questions/comments about the spell feature

Moshe Kaminsky
Hi,

I've just tried to use the spelling system. Great feature, thanks Bram!

I have some questions:

1. The help says that the .spl files are looked for in the runtimepath
   directories. It wasn't clear to me whether all of the files in all of
   the directories are appended, or just the first one is used. If the
   later, how can I add new words to the wordlist (if I want to specify
   that certain words are correct)?

2. It appears that the syntax highlighting has some special behaviour:
   The highlighting is added on top of the usual highlighting for that
   word, instead of replacing it. Is this something builtin for the
   spelling system, or can I use this with other groups as well?

3. I tried adding spelling support for perl scripts, so that spelling
   will be on only for the embedded pod documentation. The problem is as
   follows: pod can be either embedded or standalone. Therefore, there
   is separate syntax file for pod, which is included in the perl syntax
   file. In the pod.vim file I therefore add @NoSpell to various syntax
   items that should not be spell-checked. When the file is included in
   the perl.vim file, I need to use the @Spell attribute for the pod
   regions, and all the @NoSpell attributes disappear. Is there a way
   out?

Thanks,
Moshe

--
I love deadlines. I like the whooshing sound they make as they fly by.
                                        -- Douglas Adams
   
    Moshe Kaminsky <[hidden email]>
    Home: 08-9456841


attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: questions/comments about the spell feature

Bram Moolenaar

Moshe Kaminsky wrote:

> I've just tried to use the spelling system. Great feature, thanks
> Bram!

I'm glad you like it.

I don't know when you obtained the code, I just sent out a new version
last night with completely changed spell code.  The data structures have
been changed from using something complicated with hashtables, prefixes,
suffixes and pre-words to a tree system.

The tree mechanism was suggested by Olaf Seibert.  The essential tricks
are to do tail compression (tails in the tree that are identical are
shared) and store the tree in a file in such a way that we can omit most
node pointers.

I added to that binary searching for quick lookup, storing of flags and
region per word and proper case handling that allows for multi-byte
encodings.

The result is that:
- the code is much simpler, thus less chance of bugs
- the file sizes are smaller (Polish is less then half the size!)
- less memory is used by Vim
- there is no need to use affix compression for reduced size, a plain
  wordlist can be used and gives the same results

I didn't notice a difference in speed for spell checking (didn't try
measuring it).

But, the code is still new, thus look out for mistakes.  I did verify
with four languages that the good words are all found.

Once the code has been tested I'll see if other projects
(OpenOffice.org, Mozilla) are interested in sharing the code.

> I have some questions:
>
> 1. The help says that the .spl files are looked for in the runtimepath
>    directories. It wasn't clear to me whether all of the files in all of
>    the directories are appended, or just the first one is used. If the
>    later, how can I add new words to the wordlist (if I want to specify
>    that certain words are correct)?

So far only one file is used (the last one found).  This isn't working
yet.  There should be some mechanism to allow the user both to overrule
a spell file and to add to it.

> 2. It appears that the syntax highlighting has some special behaviour:
>    The highlighting is added on top of the usual highlighting for that
>    word, instead of replacing it. Is this something builtin for the
>    spelling system, or can I use this with other groups as well?

This is a special trick that's used for the spell highlighting, so that
the "undercurl" can be added without changing the other highlighting.
It's now also used for Visual selection and Search matches.  It's not
available otherwise.  And it doesn't fully work yet.

> 3. I tried adding spelling support for perl scripts, so that spelling
>    will be on only for the embedded pod documentation. The problem is as
>    follows: pod can be either embedded or standalone. Therefore, there
>    is separate syntax file for pod, which is included in the perl syntax
>    file. In the pod.vim file I therefore add @NoSpell to various syntax
>    items that should not be spell-checked. When the file is included in
>    the perl.vim file, I need to use the @Spell attribute for the pod
>    regions, and all the @NoSpell attributes disappear. Is there a way
>    out?

Currently mixing @Spell and @NoSpell doesn't work.  We could change it
such that when they are both used then spell checking is only done in
@Spell items, and disabled where @Spell and @NoSpell both appear.

--
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
                -- Arthur Dent and Ford Prefect in Douglas Adams'
                   "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: questions/comments about the spell feature

Moshe Kaminsky
Hi,

* Bram Moolenaar <[hidden email]> [05/06/05 15:20]:

>
> Moshe Kaminsky wrote:
>
> > 3. I tried adding spelling support for perl scripts, so that
> > spelling will be on only for the embedded pod documentation. The
> > problem is as follows: pod can be either embedded or standalone.
> > Therefore, there is separate syntax file for pod, which is included
> > in the perl syntax file. In the pod.vim file I therefore add
> > @NoSpell to various syntax items that should not be spell-checked.
> > When the file is included in the perl.vim file, I need to use the
> > @Spell attribute for the pod regions, and all the @NoSpell
> > attributes disappear. Is there a way out?
>
> Currently mixing @Spell and @NoSpell doesn't work.  We could change it
> such that when they are both used then spell checking is only done in
> @Spell items, and disabled where @Spell and @NoSpell both appear.
That would solve the problem. What seems to me the most reasonable from
the user's point of view is to use the @Spell/@NoSpell value of the
group with which the text is actually highlighted.

Thanks,
Moshe

>
> --
> "You know, it's at times like this when I'm trapped in a Vogon airlock with
> a man from Betelgeuse and about to die of asphyxiation in deep space that I
> really wish I'd listened to what my mother told me when I was young!"
> "Why, what did she tell you?"
> "I don't know, I didn't listen!"
> -- Arthur Dent and Ford Prefect in Douglas Adams'
>   "The Hitchhiker's Guide to the Galaxy"
>
>  /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
> ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
>  \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
>
--
I love deadlines. I like the whooshing sound they make as they fly by.
                                        -- Douglas Adams
   
    Moshe Kaminsky <[hidden email]>
    Home: 08-9456841


attachment0 (205 bytes) Download Attachment