Bugs :  K-Meleon Web Browser Forum
You can talk about issues with k-meleon here.  
Search macro issue
Posted by: zm
Date: November 01, 2002 06:19AM

Hello.

I am not sure if this is a browser or a documentation problem, but if I try to use the macros from http://kmeleon.sourceforge.net/docs/searchmacro.php I get first a popup saying how "The expression 'javascript:self.location=<snip>getSelection())' is a badly formed conditional expression" followed by another one in which the open() function complains how it got 0 args, and wanted 1.

Any ideas how to fix this?
(win95; 0.7; seen with 0.65 too)

Options: ReplyQuote
Re: Search macro issue
Posted by: po
Date: November 01, 2002 09:31AM

Those might need to be cleaned up to work with the new macro plugin in 0.7 - in fact, much of that functionality can now be achieved without using javascript... i'll try to provide some examples when i'm more awake, if someone else doesn't first...

Options: ReplyQuote
Re: Search macro issue
Posted by: zm
Date: November 02, 2002 04:26PM

Thanks. Looking forward to seeing that.

Options: ReplyQuote
Re: Search macro issue
Posted by: zm
Date: November 02, 2002 05:49PM

Well, I got imatient, and decited to read the default macro examples, and this is what I found is working:

search_google {
menu = "Search Google...";
$oldclip = getclipboard();
id(ID_EDIT_COPY);
$q = getclipboard();
$q = prompt("Enter search query:", "Google Search", $q);
open("http://www.google.com/search?client=googlet&q="; . $q);
setclipboard($oldclip);
}

The next thing is to find the way to prompt for the search string only if there is nothing selected, and use selection if it exists, like the google bookmarklet does.
After that, figure out how to make something like this running, so we can add new searches in only a few lines each:

searchGeneric {
$oldclip = getclipboard();
id(ID_EDIT_COPY);
$q = getclipboard();
$q = prompt_if_q_is_nil("Enter search query:", $searchName, $q);
open($searchURL . $q);
setclipboard($oldclip);
}

search_google {
menu = "Search Google...";
$searchURL = "http://www.google.com/search?client=googlet&q=";;
$searchName = "Google Search";
run_macro(searchGeneric);
}

search_dictionary {
menu = "Search Dictionary...";
$searchURL = "http://www.dictionary.com/search?q=";;
$searchName = "Search Dictionary";
run_macro(searchGeneric);
}

Is that doable?

zm

Options: ReplyQuote
Re: Search macro issue
Posted by: po
Date: November 02, 2002 11:07PM

Sorry for lagging, but it sounds like you've got it figured out. smiling smiley

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. smiling smiley
-------------------------------------------------------------

$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 );
}

Options: ReplyQuote
Re: Search macro issue
Posted by: zm
Date: November 03, 2002 06:07AM

ok, a that searches for the selection using the current default engine; prompts for search string if no selection:

search {
$oldclip = getclipboard();
setclipboard("");
id(ID_EDIT_COPY);
$q = getclipboard();
$terms = ($q == "" ? prompt("Enter search query:", "Search ( " . $engine . " )") : $q);
$terms == "" ? ($word = "") : macros(parse_terms);
$word == "" ? "" : open( $engine . $word );
setclipboard($oldclip);
}

This one will repeat the last search, prompting for the new default engine:

search_with_chg {
$modeswitch = prompt("Enter new search engine ID:", "Search");
macros(get_engine);
$engine = ($new_engine == "" ? $engine : $new_engine);
$word == "" ? "" : open( $engine . $word );
}

Now, we need a toolbar icon for this last one... :-)

Options: ReplyQuote
Re: Search macro issue
Posted by: po
Date: November 03, 2002 11:42PM

This could get crazy, combined with type ahead find... yikes. smiling smiley

Options: ReplyQuote


K-Meleon forum is powered by Phorum.