Customizing your RONGO

Initialization file

rongo version 0.2b or later looks at the initialization file, and load it if one found after module Rongo is defined. Thus, you can extend the module Rongo or do some default setting (like changing the default symbol size) in the initialization file.

Location of the initialization file

rongo search for the initialization file in the following order

  1. If environment variable RONGOINITRC is set and the file with that name exist, that will be the initialization file.

  2. If the environment variable is not set or the file does not exist, rongo will look at .rongoinitrc at the current directory.

  3. If that file does not exist, rongo finally will look at “$HOME/.rongoinitrc”.

Format of the initialization file

The initialization file is just loaded as usual ruby source file. So whatever you can write in ruby (at the top level) is valid. Here is the simple example of a valid initialization file (which does nothing than printing a message:


print "This is test initialization file\n"

With this initialization file, you would get something like this:

>rongo
Loading initialization file .rongoinitrc
This is test initialization file
Entering interactive mode
*

The following is a bit more interesting example:

module Rongo
  def printptparm
      print "starscale = ", @@rongostarscale, "\n"
  end
end

This extends the Rongo module, by adding method “printptparm”, which shows the value of the module variable @@rongostascale used in method putregularpolygon. This method is called from points and dots.

If you want to change this particular module variable, you can write a method like:


module Rongo

def setptparm (x)
    @@rongostarscale = x
end

end


in the initialization file. Now you have extended your rongo command.

Here, you have added your own method, but rongo commandline editing function, convert_to_good_ruby_string, does not know about your method. Thus, you cannot apply the rongo command completion. To let rongo apply command completion, you can change the values of module variables such as

@@rongospecialcommandsmultiargs
@@rongospecialcommands
@@rongonormalcommands

Here, rongospecialcommandsmultiargs is an array of commands, for which the arguments are quoted individually. The box command is an example (might be the only example at least for version 0.2b). rongospecialcommands is for commands with single argument in quoted form, such as xlabel, ylabel and label.

rongonormalcommands is for commands with non-quoted arguments, such as limits, xcolumn.

In the case of setptparm, good place to add would be rongonormalcommands. So you can write:

module Rongo
  def myinit
      @@rongonormalcommands.push("setptparm")
      setnormalcommands
  end
end
myinit

Here, setnormalcommads just update rongocommands from other subsets variables.

Note that here you defined a module instance method, and called it from the Ruby top level. This is rather handy, and is achieved by place

include Rongo

before loading the initialization file.