Note for brazilian readers: this text was already posted as “GEdit completando código Python automaticamente” and we are making it available in English now.
It’s been a while since I’ve started to develop a plugin to make Gedit able of completing python code. After a while, it became clearer that this was a functionality desired by many users and it is also of interest for the group that keeps the project. Actually, I will be posting this to the wiki of plugins of the GEdit.
So, for this to happen, I decided to take a look at the code used on Vim to complete python codes. For my surprise, that code was also written in python and after some reading, I realized that it could be ported to other text editors. One of the reasons I chose GEdit is that it makes the plugin creation process very easy and understandable by new developers (I recommend the article the Python Plugin How, which explains how to develop plugins for this editor). Using Osmo Salomaa Autocomplete words plugin, made this process even easier.
Long story short, what I did was to connect the two parts: the code for Vim auto-complete (authored by Aaron Griffin) and the code for Autocomplete words (authored by Osmo Salomaa). This is, indeed, a good example of the benefits of free software: providing easy ways for me not having to repeat the work of both authors and rendering me able to use both codes to provide a new for another text editor.
During the trip, which came up being more complicated than expected, I lost many files at my old computer, so the work was stopped until I had the guts to start again. The restart was even better: development was faster and the old errors were quickly solved.
The plugin works on Gedit through the shortcut Ctrl+Alt+Space and allows fast code completing for python scripts and python modules are also supported. Basically, it works the same way it did on Vim, apart from some small adjustments I made in the code. Aaron Griffin alerted me that the code contained some small known problems and that would be corrected soon. I will keep myself up to date with Aaron for the plugin not to become outdated.
This is an alpha version which wasn’t by any means put through rough tests yet. That said, I believe it can already be used but, surely, bugs will come up. I am available to assist whoever is interested on the plugin. On the sequence, there are some screenshots demonstrating the use of the plugin. Today, Gedit has a lot of plugins for Python development, which is taking it nearer to becoming Python development environment. But I still use Vim.
The installation of plugin is relatively easy: the user must unpack the archive into the directory gnome2/gedit/plugins of its home, restart gedit and activate plugin in edit – > preferences – > plugins. This plugin will only work with python code. I hope the community can help on the development and that it makes it more and more usable over time.
The plugin of auto complete Python code is avaliable here.