[Geany-Devel] Lua script vs the plugin wishlist

Steven Blatnick steve8track at xxxxx
Sat Jun 8 05:59:33 UTC 2013


My intent behind external-tools is to essentially imitate the functionality of gEdit's External Tools plugin.  You can try that out to see what I mean, or better yet, try my plugin out at https://github.com/sblatnick/geany-plugins in the "external-tools" branch.  I've added a make file in the directory, so you can just run "make && make install" and then enable it.

Here are some example uses, some of which I've already used in gEdit:

1. Build code with compiling output in the bottom panel.  Yes, I know that there are already build tools, but this makes building as simple as adding the command line code just as you would in the terminal, rather than figuring out all of the separate fields.

2. Replace currently highlighted text.  When trying to add localization to a JSP, I found it convenient to write a little macro that changed some.text.string to <%=SOME_TEXT_STRING%> with a press of a button.  This allows me to write perl scripts or bash scripts to replace any text.

3. Integrate database operations.  You could highlight the select query and have the output displayed in a table below.

4. Open an external tool such as meld to compare the current file against git or svn.

5. Open relevant files.  For example, I may have a .jsp open and need to open a similarly named .js and .java file related to it.  Basically I can script opening of the files not yet open as compared to the current one.

6. Run custom searching like ack-grep or tools to clean up files like html.

Basically it is very flexible without having to learn very much about the inner workings of geany like making a plugin would.  Best of all, you can use any language you want, so long as the file knows to execute it.

Another advantage is that you can add scripts and shortcuts easily, with a UI, rather than having to set up the directory structure and format yourself.

Variables are passed to the script through the environment.  Here is a good example of a script you could add to my plugin to see the variables:

#!/bin/bash
echo "GEANY_LINE_NUMBER=$GEANY_LINE_NUMBER"
echo "GEANY_SELECTION=$GEANY_SELECTION"
echo "GEANY_SELECTED_LINE=$GEANY_SELECTED_LINE"
echo "GEANY_FILE_PATH=$GEANY_FILE_PATH"
echo "GEANY_FILE_MIME_TYPE=$GEANY_FILE_MIME_TYPE"
echo "GEANY_FILE_TYPE_NAME=$GEANY_FILE_TYPE_NAME"
echo "GEANY_PROJECT_DIRECTORY=$GEANY_PROJECT_DIRECTORY"

Furthermore, I think it easier to have a single interface for building, Custom Commands, and any other functionality that could use this structure.

I plan on adding (if I can figure out how :-) the ability to have links in the text output for opening files who's paths are printed.

Of course, it's a plugin, so that allows it to be installed only if they want it.

I hope this helps,

Steve

PS: I have two other plugins I'd love to see get adopted that are in my github repo in their own branches:

quick-search: incremental search that is quicker than the ones already in geany by on a single keystroke adding to the highlighted entries and the search field any currently highlighted text.  It also doesn't occupy toolbar space, as it, like gedit's incremental search, is a non-decorated hovering window in the top left corner of the editor.  I actually like this plugin's behavior better than gedit's because it doesn't retain a list of historical values, so you don't get it auto-completing when you don't want it.

quick-opener: Open dialog that searches files in the project directory by name and allows for quick opening.  This is like the lua plugin mentioned in the mailing list, but it filters as you type.  It's configurable to skip unwanted directories and file names.


________________________________
 From: Thrawn <shell_layer-geany at yahoo.com.au>
To: Geany development list <devel at lists.geany.org> 
Sent: Friday, June 7, 2013 10:54 PM
Subject: Re: [Geany-Devel] Lua script vs the plugin wishlist
 

Hi, folks. Thanks for your feedback.

I'm only a novice with C, but I'll take a look sometime at the GeanyLua source and see whether I think I could fix something broken. Will let the list know what I decide.

@Steven: Interesting to hear about your External Tools project, because several of my Lua scripts are basically to give easy integration with external tools. What are its specific advantages compared to GeanyLua and GeanyPy?

> I think that[1] wishlist is pretty out of date, FWIW. Maybe
> we should start one on the main wiki[2] again?

Yeah, it is out of date, but still, these are things that someone wanted at some point. Seems to me like a good starting point. Feel free to update it, though. I believe a bunch of the items already exist in Geany core or a plugin, so they could be cleaned up.

> > Advanced interaction with Geany's chrome is out,
> 
> Assuming chrome means the GUI, I think there's Lua bindings
> for GTK+ and from what I've read, it's pretty
> straightforward binding C structures in Lua. If you can get
> a hold of the GeanyMainWidgets structure and/or the
> ui_lookup_object function from Lua, you should be golden.

Sadly, I can't see anything in the GeanyLua API that would give me either of those :/ Maybe that's something I can look for in the GeanyLua code.

> Oliver has GeanyPy packages on his PPA[3] for Ubuntu,
> presumably the .debs would work for other Debian-based
> distros as well.

Good to know. I might give that another look at some point.

I do still like the simplicity of the GeanyLua API, but of course, the complexity of the GeanyPy API is the price of the power.

> For the build process, I'm pretty sure it
> shouldn't require 100MB of dependencies to compile (unless
> you've never installed any build tools yet, like compiler,
> autotools, etc).

OK, tried 'sudo apt-get install python python-dev python-gtk2 python-gtk2-dev' on another machine, and this time it wanted to download 57MB, or 41MB without installing recommendations. Better, but still quite a bit, when you consider the size of the main Geany package. And then you still need to download the actual plugin source, compile and install it, and you won't be able to manage it via your package manager.

I work as a programmer, so none of that is a big deal for me. But it's enough for me to prefer GeanyLua for jobs that it can handle. And there are enough of those to keep me busy for a while.

> Anyway, cool that you gave GeanyPy a look, sad that it got
> overlooked for another alternative :) It's a weird
> situation, no uses it because no uses it[4] :)

Well, if it were available from the default repositories, I'd probably use it. Does it actually have to be part of geany-plugins for that?

You could try porting some of my scripts to GeanyPy if you want. They're GPL and all quite short. Have you tried them out?

> [4] Lex, before you say "because it's not in Geany-Plugins",
> patches welcome on integrating GeanyPy's complex build
> systems into both of Geany-Plugin's even more complex build
> systems, oh and (non-trivial) upgrading to GTK3 and
> Gobject-Introspection-based PyGTK for GTK3 :)

:s No wonder GeanyLua is in peril. Sounds like you have a hard road ahead for GeanyPy, but I do sincerely wish it well, and will keep my eye on news of it.

And I have taken note of the fact that GeanyPy crumbles yet another of the few advantages of Gedit, the ability to integrate a Python console.

Will email the list again soon. I'm working on a Lua script to give Vim keybindings. It's actually quite simple! There are a lot of keys to do, that's all.

Thrawn
_______________________________________________
Devel mailing list
Devel at lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20130607/d902bbf2/attachment-0001.html>


More information about the Devel mailing list