Tuesday, 25 January 2011

Custom Search in Firefox and Chrome

I was toying with Chrome on my Eee PC, partly for experimentation and partly because of the slightly-more-efficient use of the 10" screen. Alas, the experiment is on hold as my Eee was liberated from my parents' home in Cape Town while I was there over Christmas. I guess I should've remembered to install Prey...

Back on track, I found Chrome's default search inferior to Firefox's, so I went looking for a fix. In the process I've learned a bit more about the custom search tools available in both Chrome and Firefox. Now I'm recording it here, for your perusal (and probably mine after I've forgotten such tricks).

For the record, these tips were tested on Firefox 3.6.13 and Chrome 8. Major revisions are coming and might change some details.

Restoring Firefox-like behaviour in the Chrome address bar

The "problem" I had was that typing a string into Chrome's address bar would produce a Google search. Not really a problem, but I prefer Firefox's use of Google's "I'm Feeling Lucky" button. Basically, if Google's first hit is really spot on, it'll take you straight to that page. For example, if you type "met office cambridge" into Firefox's bar, you'll get the Met Office forecast for Cambridge. In Chrome, that will be the first hit, but you still need that extra click.

The fix is to change the default search behaviour to use the "I'm Feeling Lucky" feature. I found the explanation on this blog but I'll restate it here for you. First, go to your Chrome options and choose "Basics". Choose "Manage" next to default search and add a search with this URL

{google:baseURL}search?btnI=I%27m+Feeling+Lucky&q=%s

Make that the default and you're set.

Other custom searches in Chrome

The custom searches are quite straightforward: Chrome just passes the string you enter in the address bar to the URL template you provide. The keywords are really useful, though. If you have (or add) a search for Wikipedia like

http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=%s

and assign it the keyword "wiki", then typing "wiki electric field" in the address bar will use Wikipedia's search to find articles related to "electric field". Note that this is different to using "site:en.wikipedia.org" as a Google search argument. It's as if you're typing "electric field" straight into the Wikipedia search.

Other things you might want could be Youtube or Google Maps.

http://www.youtube.com/results?search_query=%s
http://maps.google.com/maps?f=q&source=s_q&hl=en&q=%s

In fact, it's not hard to add anything. This blog explains. The long and short is to go to your desired custom search, search something, copy the consequent URL and replace the argument you used with "%s". Assign keywords and you'll save yourself some clicks.

Custom searches in Firefox

Little did I know the keyword trick is available in Firefox too. You can see a list of search engines available from the drop down menu next to the search bar. Click "Manage Search Engines..." and you'll be able to add keywords to the searches that are in the list. These work the same way as for Chrome as described above. Arguments entered in the search bar will still use the selected engine.

To add new searches in Firefox, go to the site, click the search bar drop menu and select "Add <site>". You can add a keyword later. You can also hit the "Get more search engines..." link for even more searches, including some that you can't add with the first method. For example, I can't add Google Maps in Firefox without downloading the Add-On.

Now, if I only I could find a way of getting this keyword/search-engine behaviour on Android's Google search widget...

Friday, 21 January 2011

Notes and tasks with Emacs' Org-Mode

In Afrikaans, I would be described as loskop. That probably translates best as "absent-minded" but, as ever, Afrikaans' simplicity cuts to the point: I really do just lose my head. Since I tried Tasks in Gmail, I've been looking for a superior way of keeping together everything from lists of books I want to read, things I need to pay and notes for upcoming blog posts. I've discovered I needed to look no further than the nearly omnipotent text editor: Emacs. I probably should never have doubted that it had this ability. Forgive me, Emacs-god. (Is there a M-x finish-phd command yet?)

Basic functionality is pretty straightforward. I haven't tried anything particularly advanced yet. Start Emacs and enter the command M-x org-mode. Obviously, if you get errors at this point, then you probably need to install the org-mode extension. The feature I yearned for, given its annoying absence from Tasks, is being able to nest collections of tasks or notes into collapsible trees. To make a collapsible heading, precede it with *. If you want a second-order heading, precede it with **. And so on. You can enter text under these headings and it, too, will collapse. To (un)collapse things, just hit Tab while the cursor is on that line.

For example, you could type the following.

* Notes
** Google CEOs
-- Eric Schmidt (til April 4)
-- Larry Page (after April 4)
** Perfect numbers
-- 6
-- 28
* Shopping list
- bread
- milk

Hitting Tab while on the "Google CEOs" line will reduce it to

* Notes
** Google CEOs...
** Perfect numbers
-- 6
-- 28
* Shopping list
- bread
- milk


Hitting Tab over "Notes" gives

* Notes...
* Shopping list
- bread
- milk

Tab again will re-open them to their previous state. It's all stored as plain text, so you can modify the file without Emacs, but you won't get the collapsibility and syntax-highlighting.

Org-mode can do much, much more, including setting deadlines and timestamping, never mind a bottomless bucketworth of C-c type shortcuts. You'll find more complete guides with a Google search but if you're lazy, here's The Compact Org-mode Guide and an article at Linux Journal.