Spell checking with ne

35 views
Skip to first unread message

michel

unread,
Feb 16, 2014, 2:32:23 AM2/16/14
to nicee...@googlegroups.com
Spell checking with ne

Can I spell checking the active file?
Ne can not spell checking itself.
My spell checker is aspell.
I feel that is a candidate for macro.
How does macros work? Can I use shell commands inside the macros?

Thanks for help.
Michael

Jamie Lentin

unread,
Feb 17, 2014, 5:37:35 AM2/17/14
to nicee...@googlegroups.com
On 2014-02-16 7:32, michel wrote:
> Spell checking with ne
>
> Can I spell checking the active file?
> Ne can not spell checking itself.
> My spell checker is aspell.
> I feel that is a candidate for macro.

Yes, a macro is what you want.

> How does macros work?

ne can be driven by text commands[0], you can create them either by
recording your own keypresses, or creating a file with one command per
line.

> Can I use shell commands inside the macros?

Yes, either using system[1] or through[2]. Which depends on what
precisely you want to do.

> Thanks for help.
> Michael

[0] http://ne.dsi.unimi.it/docs/Commands.html
[1] http://ne.dsi.unimi.it/docs/System.html
[2] http://ne.dsi.unimi.it/docs/Through.html

Michel

unread,
Feb 18, 2014, 2:29:05 PM2/18/14
to nicee...@googlegroups.com


On Mon, 17 Feb 2014, Jamie Lentin wrote:


> On 2014-02-16 7:32, michel wrote:
> > Spell checking with ne
> >
> > Can I spell checking the active file?
> > Ne can not spell checking itself.
> > My spell checker is aspell.
> > I feel that is a candidate for macro.
>
> Yes, a macro is what you want.
>
> > How does macros work?
>
> ne can be driven by text commands[0], you can create them either by recording
> your own keypresses, or creating a file with one command per line.
>
> > Can I use shell commands inside the macros?
>
> Yes, either using system[1] or through[2]. Which depends on what precisely you
> want to do.
>
With through cmd I had any success-less experiments before.
It's usual for 'sort' od 'date', not for spell checking.

The sys cmd command and 'aspell --check --lang de ACTIVE_FILE'
start spell checking well,
but after aspell ne falls back to the state before.

Michael

utoddl

unread,
Feb 18, 2014, 5:09:16 PM2/18/14
to nicee...@googlegroups.com
aspell works on a file, not a stream. The 'through' command works on streams, so you'd need to approach it another way.

Put the following lines in ~/.ne/aspell

Cut
SaveClip /tmp/ne-aspell.txt
System aspell --check /tmp/ne-aspell.txt
OpenClip /tmp/ne-aspell.txt
Paste


This will be your new "aspell" macro. Now load a document. Go to the beginning of a section you want to spellcheck with aspell and set the mark (^B). Then move to the end of the section you want to check.

Now invoke your "aspell" macro. The first command will cut the section you've selected from your document. The 2nd command saves that clip to a file. The 3rd command runs aspell (the program, not the macro) on that file. The 4th command loads the spellchecked text into the default clip. And finally the 5th command pastes the checked text back into the document where the original selection came from.

BEWARE: If you find yourself tweaking the ~/.ne/aspell macro, be sure to invoke the UnloadMacros command after changing it; otherwise ne will use  its cached copy of the older version.

Also, this doesn't deal with multiple people on the same system using the same macro, and it leaves potentially sensitive information lying around int /tmp/ne-aspell.txt. You should probably use a private location, or clean up, or both.

Hope this helps,
Todd

utoddl

unread,
Feb 19, 2014, 10:31:35 AM2/19/14
to nicee...@googlegroups.com
Here's a somewhat nicer version of that aspell macro.

AtomicUndo +
Cut
SaveClip ~/.ne/ne-aspell.txt
System aspell --check ~/.ne/ne-aspell.txt
OpenClip ~/.ne/ne-aspell.txt
System rm ~/.ne/ne-aspell.txt
Paste
AtomicUndo -

Note the use of AtomicUndo at the start and end. This makes a single Undo revert all the changes the macro makes: the Cut and the Paste. A subsequent Redo will behave similarly.

This version also uses a scratch file in your private ~/.ne directory rather than /tmp, so other users won't see your text. (They still may be able to, depending on your ~/ and ~/.ne permissions.) It also goes to the trouble to remove the scratch file when it's no longer needed.

Michel

unread,
Feb 19, 2014, 1:41:58 PM2/19/14
to nicee...@googlegroups.com




> Here's a somewhat nicer version of that aspell macro.
>
> AtomicUndo +
> Cut
> SaveClip ~/.ne/ne-aspell.txt
> System aspell --check ~/.ne/ne-aspell.txt
> OpenClip ~/.ne/ne-aspell.txt
> System rm ~/.ne/ne-aspell.txt
> Paste
> AtomicUndo -
>
> Note the use of AtomicUndo at the start and end. This makes a single Undorevert all the changes the macro makes: the
> Cut and the Paste. A subsequent Redo will behave similarly.
>
> This version also uses a scratch file in your private ~/.ne directory
> rather than /tmp, so other users won't see your text. (They still may be
> able to, depending on your ~/ and ~/.ne permissions.) It also goes to the
> trouble to remove the scratch file when it's no longer needed.

That's it!
That's work.

Thank you.
Michael

Storm Dragon

unread,
Apr 9, 2019, 5:58:51 PM4/9/19
to niceeditor
Hi,

Is there any way to select the whole document for spellchecking without having to manually mark the begenning and then go to the end?

todd_...@unc.edu

unread,
Apr 10, 2019, 8:20:13 AM4/10/19
to niceeditor
Sure. Add to the start of the "aspell" macro the commands:

MoveSOF
Mark
MoveEOF

Technically, I guess that doesn't avoid marking at the beginning and then go to the end, but it at least automates it.

If you put your modified "aspell" macro in your ~/.ne directory, then it will take precedence over the one in /usr/share/ne/macros.

Storm Dragon

unread,
Apr 10, 2019, 6:42:50 PM4/10/19
to nicee...@googlegroups.com
Hi,

Thanks for the help, I was on the right track but it didn't work for me. The missing piece of the puzzle was UnloadMacros. Once I did that it worked awesomely.

Thanks,
Storm
>--
>You received this message because you are subscribed to the Google Groups "niceeditor" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to niceeditor+...@googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.


--
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
"Pray nightfall release me, then I could wander to deep sleep."
Paradise Lost - Pray Nightfall
signature.asc
Reply all
Reply to author
Forward
0 new messages