[Geany-devel] PlugIn for Ruby Refactoring / Help overriding callbacks

Lex Trotman elextr at xxxxx
Tue Oct 2 01:17:23 UTC 2012

On 2 October 2012 00:00, Rory Michele <zaibatzu at gmx.net> wrote:

> Hi guys,
> I'm looking for help. To give you my level: I work as a (mostly ruby and
> java) programmer and have some experience on that level, but this would
> be my first bigger open-source project that I work on. So please be kind ;)

Hi Welcome,

> I would like to write a geany plugin trying to provide helpful ruby
> refactoring (I think thats the word, what I mean is looking up
> (possible) declarations and usages), that can extend or replace the
> functionality of "go to tag declaration/definition". I wish for that
> because the current implementation looks only in open files as far as I
> understand and I would like to provide this on a project basis, therefor
> scanning also files not currently opened in geany.

Have you looked at both the project plugins, I think one or both do this?

> I know this is very intensiv to provide for ruby, however I'm thinking
> to provide it only at explicit wish (e.g. special button), not to bother
> the slim and fast design of geany. And as I'm doing the same for
> "reverse engineering"/understanding geany right now with grep, I think
> it should be possible at reasonable speed, unlike these java
> implementations that they scan and index all at the beginning and kill
> my memory ;) Now what do you think, is it appropriate to provide this
> for geany or is it against a concept or something?

I am not sure I understand what you are proposing, since would your plugin
not also "kill your memory" if it scans everything? It just won't do it
until you press the magic key.

> The features I currently have in mind:
>  - a menu-point and keybinding for navigating to possible declarations
>  - a second mode for auto-completion (maybe pressing space another
> time), that looks up possible classes the selected instance is of, to
> show only relevant tags for autocompletion
>  - a menu-point and keybinding for listing possible usages (and the
> possibility to navigate there)

Just from a user point of view it might be better if your plugin just
replaced the Geany functionality rather than being an additional function,
but I guess that can be found by experiment.

The only one of the above that might be difficult(ish) is the second mode
which seems to depend on a key sequence not a simple binding.  Its not
impossible, just Geany doesn't do that and so will give you no assistance.
 Might be better as another keybinding.

> Now the Questions:
> I checked the demoplugin so in general I think I have a clue on how to
> create the plugin.
> Now what seems for me the best way to go would be to simple override the
> callbacks for the existing "Go to Definition" etc. keybindings (as the
> ui-buttons seem to also be using them).

The first relevant key_binding_id I would like to overide the callback
> And it is mapped to a function in keybindings.c on line 1886.
> Now, this mapping I would like to overide. Is that possible and how? Or
> do I have to create new UI-Elements and link them to my function. I
> would not like the latter so much as the global settings for keybindings
> wouldn't have effect, wouldn't they?

Hmmm, normally plugins don't override existing keybindings, and there is an
argument that they should not set any keybindings until the user selects
which ones to use.  This is since the user can re-assign keycodes and the
plugin can't tell what system or other plugins may be using a particular
keycode.  Even if it could tell, it would normally be considered to be rude
to just splatter over it :(  This has been a problem in the past with
disagreements between plugins.

Normally plugins just add another keybinding section and let the user
assign codes, see for instance some of the plugins included with Geany for
how to (reasonably) conveniently do this.

As I noted above, in this case you may want to replace the normal
functionality when your plugin is active, but I'm not sure it is possible
at this time and you might have to intercept the keypress and grab it
before Geany sees it.  That of course adds complexity to your plugin and
makes the keybinding preferences settings wrong.


> Thanks for your help and I'll be happy to clarify any questions
> rory
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20121002/63a60056/attachment.html>

More information about the Devel mailing list