HomerEditor


This section quickly explains how to use HomerEditor, the Homer scripts editor. The HomerEditor executable lives in ~/config/bin/. It can be launched by double-clicking on its icon, typing HomerEditor in a Terminal, or from Homer, the script launcher.

HomerEditor.gif (9382 bytes)

Homer scripts live in ~/config/settings/Homer/scripts. A Homer script has:


Loading or resetting a script

Next to the script name, you find 2 buttons. The first one ("...") opens a file selector to load a script. Alternatively, you can drag'n drop script files into the window.
The "x" button resets the contents of the current script: the parameters list and body are made empty.


The parameters

The way Homer treats a script parameter is somewhat different from what one would expect. Parameters are only strings which will be substituted in the script body at run time It may not be clear at the moment, but if you look at the picture above, you'll notice that the body script consists of one "search" command (actually the GrepCommand, see in bundled Homer commands). As the argument, you see "$1" which stands for the first parameter (much like in a shell script). As the first (and only) parameter, you see I have added a "search for:" parameter. This actually stands for the label which will be used by Homer in its parameters list, so it is not exactly a parameter, but rather a parameter label. See the picture below:

HomerParameter.gif (25869 bytes)

The "search for:" parameter ($1) declared in HomerEditor is used as a label in the script parameter in Homer. Moreover, the value that the user will type for $1 will be replaced in the script body wherever $1 appears (in that case, it is in the search command). Unfortunately, it would be a little bit too sophisticated (read "I'm too damn lazy") to support parameter types like "boolean" or "one_of foo, bar, ...". So we all have to stick with these string-based parameters.

You add a parameter label by clicking on the "+" button in the script view (if the label is non empty). You can remove selected parameter label by clicking on the "x" button. You are limited to 9 parameters ($1 to $9).

$0 is a special string which is interpreted as the full path for the entry which is being processed. One can imagine dozens of such special values, but so far, only $0 to $9 are supported.


Editing the script body

To start with, one bad news: You can't do everything you might need with the script. Even though AND and OR conditions are supported, they can't be nested, just like in any regular programming language. Homer only supports simple AND/OR statements (well, at least, not nested). For instance, the body:

filter1 AND filter2 AND filter3 OR filter4 AND filter5 OR filter6 OR filter7 command1 filter8 command2

is interpreted as:

IF ((filter1 AND filter2 AND filter3)
    OR (filter4 AND filter5)
    OR (filter6)
    OR (filter7)) THEN
    command1
ELSE IF (filter8)
    command2
ENDIF

Basically, a condition is terminated by a command. As you can see, it doesn't mean that conditions are too simple to do anything. This was about the bad news.

Now the good news is that is very easy to edit the script body. You have a filters view and a commands view. In the filters view, depending on the context, you can add an AND or an OR filter thanks to the "and" and "or" buttons. The "x" button is used to remove the last filter. You can't remove a filter unless it is at the end of the body. I know it's not convenient, but... I'm lazy. This also applies to the commands view.
In the commands view, you can add or remove the command at the bottom of the body with the "+" and "x" buttons.

You also have a "?" button that will give you the add-ons information (author name, email, ...)


Saving and Quitting

Nothing much to say about the buttons at the bottom of the window. "Save prefs" saves the preferences (the window frame). The "?" button let you know that I'm the author of Homer. "Quit" quits the application and "Save" saves the current script if a name is given.
A few things are missing like an alert box to ask "do you really want to quit?" and "the current script is modified, your changes might be lost...", but it seems so useless to me...

Well, that's it. I suggest that you start writing your own add-ons right away.


This page was last updated on 12/12/99.