07/09/2008
Google Region
Somehow, this didn't occur to me until today: it would be really great to select some text and enter a key command to search for that text on google. It may have taken me a long time to realize I wanted something like that, but I've used it today more times than I'd like to admit.
Anyways, here's how to make that happen in emacs, complete with a "control-c g" shortcut.
;; google-region (defun google-region (&optional flags) "Google the selected region" (interactive) (let ((query (buffer-substring (region-beginning) (region-end)))) (browse-url (concat "http://www.google.com/search?ie=utf-8&oe=utf-8&q=" query)))) ;; press control-c g to google the selected region (global-set-key (kbd "C-c g") 'google-region)