K-Meleon
Macro Language
The macros.cfg file is parsed top to bottom. It's only read in once. That means you have to define things above where they are used. This will make sense to programmers Everyone else, don't worry about it.
??? Maybe this is only true for variables, not macros.. ??? Comments
A line that starts with # is a comment and is ignored.
Variables and Macros
Variables are not declared explicitely, but must have a name starting with a dollar sign. A variable can either be global, accessable from by macros, or local to a specific macro. Before a variable can be used in an expression it must be assigned a value. Boolean values, integer values and string values are available.
When needed, a variable is automatically be converted from a string to an integer, or the other way around.
Macro declarations consist of a macro name followed by a compound of statements to execute for that macro. An optional assignment of a string value to 'menu' can be used to set the text shown when the macros is used in menus.
Expressions
The following operators are available:
+ addition $x = 7 + 3; 10 - subtraction $x = 7 - 3; 4 * multiplication $x = 7 * 3; 21 / division $x = 7 / 3; 2 % remainder $x = 7 % 3; 1 equal $x = 7 3; 0 ??? false ??? != not equal $x = 7 != 3; 1 ??? true ??? . concatenation $x = 7 . 3; 73 ? : conditionals $x = $y1 ? 2:3; 2 if y 1; 3 otherwise
Parenthesis can be used to alter the evaluation order.
Strings
Strings should be enclosed in double quotes although not required unless the string contains operators. A backslash is used as escape character to enter special characters.
\\ backslash \n newline \r carrige return \" quotation mark
Global Variables
There is a number of predefined global variables to let K-Meleon macros access some global state information.
$URL
Statements
Several statements can be lined up on the same line with a semicolon in between.
Special statements:
open( URL );
opennew( URL );
openbg( URL );
setpref( TYPE, "user.preference.variable", VALUE);
$VALUE = getpref( TYPE, "user.preference.variable" );
togglepref( TYPE, "user.preference.variable", VALUE1, VALUE2, ... );
exec( PROGRAM );
id( COMMAND_ID );
plugin( PLUGIN, COMMAND ); pluginmsg( PLUGIN, COMMAND, ARGS ); $REPLY = pluginmsgex( PLUGIN, COMMAND, ARGS, TYPE );
statusbar( TEXT );
alert( MESSAGE, TITLE, ICON );
$RESULT = confirm( MESSAGE, TITLE, BUTTONS, ICON );
$VALUE = prompt( PROMPT, TITLE, DEFAULT_STRING );
$TEXT = getclipboard();
setclipboard( TEXT );
$SUB = gensub( r, s, h, t );
$SUB = gsub( r, s, t );
$I = index( s, t );
$LEN = length( s );
$SUB = sub( t, s, t );
$SUB = substr( s, i , n? );
$BASE = basename( NAME , SUFFIX? );
$DIR = dirname( NAME );
$HOST = hostname( URL );
macros( MACRO );
&MACRO
Not all parameters are required for alert, confirm and prompt commands.