help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: browse select text, text at point


From: Andreas Röhler
Subject: Re: browse select text, text at point
Date: Thu, 07 Jul 2011 09:07:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11

Am 06.07.2011 21:59, schrieb Deniz Dogan:
On 2011-07-06 19:35, Andreas Röhler wrote:
Am 06.07.2011 15:43, schrieb Deniz Dogan:
On 2011-07-06 14:19, address@hidden wrote:
Hello,

I am wondering whether anyone in the group knows a package that will
accomplish the following:
- I am on a word, say "limousine", by pressing a keystroke I can browse
this word in google (or a chosen search engine) with my default
browser,
- I have selected a region of text and I want to search that text in my
default browser.

Any ideas as to how to most effectively accomplish this? Downloading a
packaged would be ideal, but I am willing to try my hand at elisp.

Stuart



Something like this should google the word at point.


(defun google-word-at-point ()
(interactive)
(let ((word (thing-at-point 'word)))
(if word
(funcall browse-url-browser-function
(concat "http://google.com/"; word))
(error "No word at point!"))))

You can either call this using M-x google-word-at-point RET or bind it
to a suitable key:

(global-set-key (kbd "C-c g") 'google-word-at-point)

You could extend the function `google-word-at-point' further to check if
`use-region-p' returns non-nil and if so use the region as the "word".

Hope that helps,
Deniz



Interesting, but get an 404 error.


That's because the URL is wrong of course. :) I couldn't bother finding
the right querystring to use. This seems to work though:

(concat "http://www.google.com/search?q=";
(url-hexify-string "Hello there"))


Deniz



thanks, BTW let's mention the code of "whois" in this context.


Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]