Integration of Edit Overflow into Geany

Using Edit Overflow directly from Geany has turned out to be surprisingly useful. If one is unsure about the spelling of a word, select it and press Ctrl + 2. The word will either 1) Be unchanged (the spelling is correct). 2) Be changed (the spelling is incorrect) 3) Have appended “@!$” (Edit Overflow doesn’t have it in its word list).

This avoids the overhead of using the web interface (even if automated by a macro keyboard as there is still the very significant delay). Though the context that the associated URL provides is absent.

It can also be used for shorthands which are then expanded by Edit Overflow, for example, with a difficult spelling and/or a long word. Example: Expanding vulns to “vulnerabilities”. Text templates can be used for the same purpose, but Edit Overflow has a lot more words.

Installation

At the moment, Edit Overflow first needs to be build/compiled on the system where you want to use it. Set up Geany to invoke Edit Overflow through its command line interface with the text selection in a Geany document, and have a script make the necessary conversions to and from Edit Overflow, similar to the ‘sort’ section in the Geany blog post.

Use this Perl one-liner on Linux:

perl -e 'while (<>) { my $out = $_; $exe = "\/home\/mortensen\/temp2\/2022-03-01\/_DotNET_tryout\/EditOverflow4\/bin\/Debug\/netcoreapp3.1\/EditOverflow3"; my $regExtr = "Corrected word for .+\\: (.+)"; my $output = qx/export LOOKUP=\"$_\"; $exe /; if ($output =~ /$regExtr/) { $out = $1; } else { my $output2 = qx/export LOOKUP=\"$_\_\"; $exe /; if ($output2 =~ /$regExtr/) { $out = $1; } else {$out .= "@!\$"; } } print "$out"; }'

Configure the $exe part. The path to the Edit Overflow executable probably needs to be changed from the default “/home/mortensen/temp2/2022-03-01/_DotNET_tryout/EditOverflow4/bin/Debug/netcoreapp3.1/EditOverflow3” (this is for a particular build folder location).

Add it to menu “Edit”“Format”“Send Selection to”“Format”“Set Custom Commands”. If it becomes the second item, then Ctrl + 2 will perform the Edit Overflow correction of the selection in a Geany document.

How does it work?

Edit Overflow has a command-line interface. For example, it can export the word list in various formats. And looking up a word in the word list is also supported. The word to be corrected is taken as the environment variable “LOOKUP” (not a command-line parameter; this is in order to avoid the complications with escaping spaces and escaping various special characters). For example, this will look up the misspelling “Javascript”:

export LOOKUP=Javascript
./EditOverflow3

where EditOverflow3 is the name of the Edit Overflow executable and the current directory is where EditOverflow3 is.

Thus the script must first take the input from standard input and set up the environment variable “LOOKUP”.

Output:

Corrected word for Javascript: JavaScript

After execution of Edit Overflow, the Perl script extracts the corrected word from that output (Edit Overflow’s output to standard output) by using the regular expression:

Corrected word for .+\\: (.+)

The Perl script only passes the correct word (“JavaScript” in this example) onto Geany (through the Perl script’s output to standard output); the Perl script acts like a filtering layer, so we get the desired result.

Leave a Reply

Your email address will not be published. Required fields are marked *

*