Perfected search functions now available
Sunday, 27. January 2008, 04:26:28
last revised August 25
Two developments (one from Opera, and one from me, Dude09 and especially Lex1):
address field search doesn't need the "g" anymore
You can now tell Opera to treat anything in the address field that's not a URL as a search string.
update: g still has a use
offered here: selected-text searches which improve on what Opera provides in four ways:
Two developments (one from Opera, and one from me, Dude09 and especially Lex1):
address field search doesn't need the "g" anymore
You can now tell Opera to treat anything in the address field that's not a URL as a search string.
update: g still has a use
offered here: selected-text searches which improve on what Opera provides in four ways:
- phrase / wordset choice
- usable with selection in editable text
- don't erase clipboard
- one-hand open-in-background (an ergonomic nicety: background launch as menu item, not requiring use of Opera's Shift+Control. Don't need to put down your coffee, lean forward, find the keyboard and do something with two hands: keep sipping, click "phrase search, background." )
Address-field search
The last of three steps has been taken to make the address field into a seamless search field. First was search, specified by a prefix letter; then came automatic search if what was in the address field was more than one word; and now we have the ability to set up automatic search on single words as well. Described by dev Martintangsl here.
Setup is 3 changes in Preference Editor; this listing shows all of them: Opera:config#hostname
- uncheck hostname expansion, to switch off automatic URL-ization (that is,addition of www. and .com) of single words (you can still URL-ize when you want to, with Ctrl+Enter).
- check hostname lookup, to enable single-word search.
- insert hostname address - for Google, it's http://www.google.com/search?q=%s. For other providers, copy from Preference dialog following Martinangsl's instructions.
And that's it.
But here's something I hadn't realized: the automatic search on multi-word strings is a phrase search, but if you put in a prefix you get a word-set search (no quotes, much broader). Not sure if it's a bug or a feature - anyhow, it creates options worth knowing about.
Selected-text search
The improvements emerged in this thread: a way to get a hotclick phrase search. (For the prior state of the art, see this discussion from 2006.)
- I pointed out that the use of capital variables (%C and %T, which add quotes around clipboard contents and current text selection respectively) made hotclick phrase search (as opposed to the usual wordset search) possible.
Example: go to page "g %T" & minimize page gives you a phrase search in a background tab. (At least, it does if "reuse current tab" is unchecked - and puts you in the wrong tab otherswise. Points out a flaw in what we can program via Opera-command macros: outcome often depends on preference settings.)
- Dude09 pointed out that a flaw in the %T variable (it doesn't work with editable text) obliged him to use %C for searching on editable-text selections (with the unwanted effect of obliterating the clipboard).
- Lex1 presented a javascript improvement on Opera's variables: a search that works on both forms of text. For good measure, he threw in a background-tab version that works regardless of preference settings.
- I pointed out that this did not as yet add the quotes a phrase search requires
- and Lex put them in.
Regarding use with one hand: Opera's notion is to provide "open in background" via the Shift+Ctrl modifier - which is perhaps a little tone-deaf about the realities of ergonomics and how people like to browse: a two-handed gesture uncongenial to those who like to slouch, curl up or sip as they work through the morning news or whatever. This wouldn't matter much if the actions tied to those gestures were available to the customizer - but they're not. Shift+Ctrl works better than anything you can set up with macros: it opens in the background, regardless of setting. That's not surprising, and the algorythm is easy to explain - but it involves things we just don't have in Opera's rudimentary macro system: sensing states and branching. So a settings-independent open-search-in-background you can put on a button or menu was not only an unprovided function: it was unconstructible with the provided macro system. (Which is when you need to call in a javascript master like Lex1... but it would be so easy, if we just had IF and status queries...)
Note: this setting must be checked to permit search results in background windows:
Preferences / advanced / content / javascript options / allow lowering of windows.
as buttons:
button: phrase search
button: wordset search
To add these functions to rightclick popup menu, copy into menu.ini:
[Selection search menu]
Item, "Phrase search, new tab" = Go to Page, "javascript: window.open('http://www.google.com/search?q=\x22'+encodeURIComponent(document.selection.createRange().text)+'\x22');void(0)",,,"zoom"
Item, "Wordset search, new tab" =Go to Page, "javascript: window.open('http://www.google.com/search?q='+encodeURIComponent(document.selection.createRange().text));void(0)",,,"zoom"
and including these lines, if you want the background-tab option (permitting the launch of several searches at once):
Item, "phrase search, &Background" =Go to Page, "javascript: window.open('http://www.google.com/search?q=\x22'+encodeURIComponent(document.selection.createRange().text)+'\x22').blur();",,,"zoom"
Item, "w&Ordset search, background" =Go to Page, "javascript: window.open('http://www.google.com/search?q='+encodeURIComponent(document.selection.createRange().text)).blur();",,,"zoom"
add this line to both Hotclick Popup Menu and Edit Widget Popup Menu (at top, if you want the initials to work):
Include, Selection Search Menu








AyushJ # 27. January 2008, 16:34
Actually, this is a old trick - http://my.opera.com/community/forums/topic.dml?id=144907
bpm # 27. January 2008, 21:34
Minor point: Shoust presents procedure as specific to "I'm feeling lucky" - which was his use, but doesn't point out more important possibility of using it for basic search (and most people don't use "I'm feeling lucky" as their normal search).
So: pref-ed settings are not new, but change in context has changed what they do. Easy to get lost among the trees. Main point here: there is unassimilated good news: a better way (in terms of simplicity and space efficiency) to set up search has become possible, is not generally understood or used - and deserves to be made the default.
Ask yourself: why are people still using the "g" prefix? Answer must be that they think it's still necessary. If you think about it, they're hallucinating - governed by false images, living in the past. The Opera user community - in the grip of a hallucination bubble. That's reality; takes a strange person to see it (in this matter, and in graver ones as well).
lem729 # 4. July 2008, 16:44
Now if I want to change search engines for the address bar, that would take more fiddling. That's why I think it's good to keep the small drop-down search bar -- for other search engines. To avoid that fiddling.
Also, interestingly the Supernova skin, http://my.opera.com/community/customize/skins/?search=supernova&x=0&y=0
has an Ask search box built into it (for the background to the Speed Dial), so that's another easy search option (from the Speed dial), as long as one uses that skin.
Lex1 # 5. July 2008, 08:43
annafil # 22. July 2008, 19:34
jabu2oz # 9. August 2008, 15:20