Sorry for lagging, but it sounds like you've got it figured out.
Below is my current search macro, bound to Ctrl+G, which is based on a structure that Ulf came up with as an improvement on a much less elegant idea presented here:
http://kmeleonbrowser.org/forum/read.php?f=2&i=1159&t=1159
It defaults first time to google, thereafter to the last used engine, otherwise uses the engine specified by the switch you enter ahead of the search terms... works pretty well, and illustrates the use of the one-line conditional statements available within macros. Probably you could figure out how to check for a text selection using these, if you wanted. It's a good idea... if i get a chance, i'll probably play with it myself.
-------------------------------------------------------------
$engine = "
http://www.google.com/search?num=64&q=";
$terms = "";
$modeswitch = "";
$word = "";
$new_engine = "";
get_engine {
$new_engine = "";
$modeswitch == "d" ? $new_engine = "
http://dict.org/bin/Dict?Form=Dict2&Database=*&Query=" : 0;
$modeswitch == "mw" ? $new_engine = "
http://www.m-w.com/cgi-bin/dictionary?" : 0;
$modeswitch == "dict" ? $new_engine = "
http://www.dictionary.com/search?q=" : 0;
$modeswitch == "w" ? $new_engine = "
http://www.wikipedia.org/w/wiki.phtml?search=" : 0;
$modeswitch == "g" ? $new_engine = "
http://www.google.com/search?num=64&q=" : 0;
$modeswitch == "gg" ? $new_engine = "
http://groups.google.com/groups?q=" : 0;
$modeswitch == "gi" ? $new_engine = "
http://images.google.com/images?q=" : 0;
$modeswitch == "gn" ? $new_engine = "
http://news.google.com/news?q=" : 0;
$modeswitch == "ga" ? $new_engine = "
https://answers.google.com/answers/main?cmd=search&qtype=all&q=" : 0;
$modeswitch == "gaa" ? $new_engine = "
https://answers.google.com/answers/main?cmd=search&qtype=answered&q=" : 0;
$modeswitch == "gau" ? $new_engine = "
https://answers.google.com/answers/main?cmd=search&qtype=unanswered&q=" : 0;
}
parse_terms {
$i = index($terms, " ");
$modeswitch = ($i != -1 ? substr($terms, 0, $i) : "");
macros(get_engine);
$word = ($new_engine == "" ? $terms : substr($terms, $i+1));
$engine = ($new_engine == "" ? $engine : $new_engine);
}
search {
$terms = prompt("Enter search query:", "Search ( " . $engine . " )");
$terms == "" ? ($word = "") : macros(parse_terms);
$word == "" ? "" : open( $engine . $word );
}