* browse select text, text at point
@ 2011-07-06 12:19 smclean0640
2011-07-06 13:43 ` Deniz Dogan
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: smclean0640 @ 2011-07-06 12:19 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 12:19 browse select text, text at point smclean0640
@ 2011-07-06 13:43 ` Deniz Dogan
2011-07-06 17:35 ` Andreas Röhler
2011-07-06 15:26 ` Drew Adams
2011-07-06 19:42 ` Thamer Mahmoud
2 siblings, 1 reply; 11+ messages in thread
From: Deniz Dogan @ 2011-07-06 13:43 UTC (permalink / raw)
To: help-gnu-emacs
On 2011-07-06 14:19, smclean0640@gmail.com 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: browse select text, text at point
2011-07-06 12:19 browse select text, text at point smclean0640
2011-07-06 13:43 ` Deniz Dogan
@ 2011-07-06 15:26 ` Drew Adams
2011-07-08 12:05 ` Stuart McLean
2011-07-06 19:42 ` Thamer Mahmoud
2 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2011-07-06 15:26 UTC (permalink / raw)
To: smclean0640, help-gnu-emacs
> - 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.
http://www.emacswiki.org/emacs/CategoryWriting
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 13:43 ` Deniz Dogan
@ 2011-07-06 17:35 ` Andreas Röhler
2011-07-06 19:59 ` Deniz Dogan
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Röhler @ 2011-07-06 17:35 UTC (permalink / raw)
To: help-gnu-emacs
Am 06.07.2011 15:43, schrieb Deniz Dogan:
> On 2011-07-06 14:19, smclean0640@gmail.com 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.
BTW would build something from
w3m-browse-url
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 12:19 browse select text, text at point smclean0640
2011-07-06 13:43 ` Deniz Dogan
2011-07-06 15:26 ` Drew Adams
@ 2011-07-06 19:42 ` Thamer Mahmoud
2011-07-07 8:24 ` Deniz Dogan
2011-07-07 9:24 ` Jonathan Groll
2 siblings, 2 replies; 11+ messages in thread
From: Thamer Mahmoud @ 2011-07-06 19:42 UTC (permalink / raw)
To: help-gnu-emacs
smclean0640@gmail.com writes:
> 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.
>
The following code should handle both words at point and region. Just do
"M-x google" or "C-c g" + ENTER.
(defun tma-word-or-region-at-point ()
"Return the word or region at point."
(if mark-active
(buffer-substring (region-beginning) (region-end))
(word-at-point)))
(defun tma-interactive-with-default ()
"Allow a user to enter a search word or phrase, but give a sane default."
(list (let* ((default-entry (tma-word-or-region-at-point))
(input (read-string
(format "Search%s: "
(if (string= default-entry "")
""
(format " (default %s)" default-entry))))))
(if (string= input "")
(if (string= default-entry "")
(error "User must provide word or region.")
default-entry)
input))))
(defun google (word)
"Use google to search for word or region."
(interactive
(tma-interactive-with-default))
(browse-url (concat "http://www.google.com/search?q=" word)))
(global-set-key (kbd "C-c g") 'google)
--
Thamer
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 17:35 ` Andreas Röhler
@ 2011-07-06 19:59 ` Deniz Dogan
2011-07-07 7:07 ` Andreas Röhler
0 siblings, 1 reply; 11+ messages in thread
From: Deniz Dogan @ 2011-07-06 19:59 UTC (permalink / raw)
To: help-gnu-emacs
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, smclean0640@gmail.com 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 19:59 ` Deniz Dogan
@ 2011-07-07 7:07 ` Andreas Röhler
2011-07-07 7:28 ` Deniz Dogan
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Röhler @ 2011-07-07 7:07 UTC (permalink / raw)
To: help-gnu-emacs
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, smclean0640@gmail.com 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-07 7:07 ` Andreas Röhler
@ 2011-07-07 7:28 ` Deniz Dogan
0 siblings, 0 replies; 11+ messages in thread
From: Deniz Dogan @ 2011-07-07 7:28 UTC (permalink / raw)
To: help-gnu-emacs
On 2011-07-07 09:07, Andreas Röhler wrote:
> 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, smclean0640@gmail.com 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.
>
What?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 19:42 ` Thamer Mahmoud
@ 2011-07-07 8:24 ` Deniz Dogan
2011-07-07 9:24 ` Jonathan Groll
1 sibling, 0 replies; 11+ messages in thread
From: Deniz Dogan @ 2011-07-07 8:24 UTC (permalink / raw)
To: help-gnu-emacs
On 2011-07-06 21:42, Thamer Mahmoud wrote:
> smclean0640@gmail.com writes:
>> 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.
>>
>
> The following code should handle both words at point and region. Just do
> "M-x google" or "C-c g" + ENTER.
>
> (defun tma-word-or-region-at-point ()
> "Return the word or region at point."
> (if mark-active
> (buffer-substring (region-beginning) (region-end))
> (word-at-point)))
>
It would make more sense to use `use-region-p' here.
> (defun tma-interactive-with-default ()
> "Allow a user to enter a search word or phrase, but give a sane default."
> (list (let* ((default-entry (tma-word-or-region-at-point))
> (input (read-string
> (format "Search%s: "
> (if (string= default-entry "")
> ""
> (format " (default %s)" default-entry))))))
> (if (string= input "")
> (if (string= default-entry "")
> (error "User must provide word or region.")
> default-entry)
> input))))
>
> (defun google (word)
> "Use google to search for word or region."
> (interactive
> (tma-interactive-with-default))
> (browse-url (concat "http://www.google.com/search?q=" word)))
>
> (global-set-key (kbd "C-c g") 'google)
>
Deniz
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 19:42 ` Thamer Mahmoud
2011-07-07 8:24 ` Deniz Dogan
@ 2011-07-07 9:24 ` Jonathan Groll
1 sibling, 0 replies; 11+ messages in thread
From: Jonathan Groll @ 2011-07-07 9:24 UTC (permalink / raw)
To: Thamer Mahmoud, help-gnu-emacs
On Wed, 06 Jul 2011 22:42:30 +0300, Thamer Mahmoud <thamer.mahmoud@gmail.com> wrote:
> smclean0640@gmail.com writes:
> > 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.
> >
>
> The following code should handle both words at point and region. Just do
> "M-x google" or "C-c g" + ENTER.
>
> (defun tma-word-or-region-at-point ()
> "Return the word or region at point."
> (if mark-active
> (buffer-substring (region-beginning) (region-end))
> (word-at-point)))
>
> (defun tma-interactive-with-default ()
> "Allow a user to enter a search word or phrase, but give a sane default."
> (list (let* ((default-entry (tma-word-or-region-at-point))
> (input (read-string
> (format "Search%s: "
> (if (string= default-entry "")
> ""
> (format " (default %s)" default-entry))))))
> (if (string= input "")
> (if (string= default-entry "")
> (error "User must provide word or region.")
> default-entry) input))))
>
> (defun google (word)
> "Use google to search for word or region."
> (interactive (tma-interactive-with-default))
> (browse-url (concat "http://www.google.com/search?q=" word)))
>
> (global-set-key (kbd "C-c g") 'google)
>
Almost there - think it'll need some string escaping, as a search on
"google+ emacs client" dropped the "+".
Cheers,
Jonathan
--
jjg: Jonathan J. Groll : groll co za
has_one { :blog => "http://bloggroll.com" }
Sent from my computer device which runs on free software
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: browse select text, text at point
2011-07-06 15:26 ` Drew Adams
@ 2011-07-08 12:05 ` Stuart McLean
0 siblings, 0 replies; 11+ messages in thread
From: Stuart McLean @ 2011-07-08 12:05 UTC (permalink / raw)
To: thamer.mahmoud; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 127 bytes --]
>
> Hello,
>
Thank you for the response! Thamer's code worked for me, I will try to come
up with something of my own.
Stuart
[-- Attachment #2: Type: text/html, Size: 309 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-07-08 12:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-06 12:19 browse select text, text at point smclean0640
2011-07-06 13:43 ` Deniz Dogan
2011-07-06 17:35 ` Andreas Röhler
2011-07-06 19:59 ` Deniz Dogan
2011-07-07 7:07 ` Andreas Röhler
2011-07-07 7:28 ` Deniz Dogan
2011-07-06 15:26 ` Drew Adams
2011-07-08 12:05 ` Stuart McLean
2011-07-06 19:42 ` Thamer Mahmoud
2011-07-07 8:24 ` Deniz Dogan
2011-07-07 9:24 ` Jonathan Groll
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).