From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Magnus Henoch Newsgroups: gmane.emacs.help Subject: Re: call google from emacs Date: Sat, 25 Nov 2006 22:01:43 +0100 Message-ID: <87slg7w894.fsf@freemail.hu> References: <877ixjjr1x.fsf@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1164488549 5134 80.91.229.2 (25 Nov 2006 21:02:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Nov 2006 21:02:29 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 25 22:02:27 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Go4fH-0008Or-4a for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 22:02:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Go4fG-0004qn-Qs for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 16:02:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Go4f0-0004lM-BE for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 16:02:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Go4ex-0004ig-5M for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 16:02:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Go4ew-0004iE-Qf for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 16:02:02 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Go4ew-0000TP-3r for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 16:02:02 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Go4er-0008Iz-8C for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 22:01:57 +0100 Original-Received: from etthundrat.olf.sgsnet.se ([193.11.222.85]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Nov 2006 22:01:57 +0100 Original-Received: from mange by etthundrat.olf.sgsnet.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Nov 2006 22:01:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-To: help-gnu-emacs@gnu.org Original-Lines: 91 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: etthundrat.olf.sgsnet.se Mail-Copies-To: never Jabber-Id: legoscia@jabber.cd.chalmers.se User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (berkeley-unix) Cancel-Lock: sha1:VvAqD3/iTDW34qz94NOoNAs38+Y= X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:38991 Archived-At: --=-=-= Hadron Quark writes: > Could someone maybe provide some elisp to bring up external browser > calling google with the hilited text? The attached is what I use; a slightly hacked copy of something I've forgotten where I found. Magnus --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable ;;; google.el --- Use current XEmacs selection as Google query. ;; Copyright (C) 2001 Erik Arneson ;; ;; Author: Erik Arneson ;; Maintainer: erik@aarg.net ;; Created: Jun-06-2001 ;; Version: 0.50 ;; Keywords: extensions, web, search, google ;; ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published ;; by the Free Software Foundation; either version 2, or (at your ;; option) any later version. ;; ;; This file is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this file; see the file COPYING. If not, write to the ;; Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA ;; 02111-1307, USA. ;; ;;; Commentary: ;; ;; Map this to a global key. I use `C-c s'. Highlight something in ;; XEmacs, hit this key sequence, and the highlighted region will be ;; sent to Google. ;;; Changelog (sort of) ;; ;; I hacked this a bit, created google-it and made it interactive. ;; Removed XEmacs-isms - buf was bound to (current-buffer) and passed ;; to region-{beginning,end} and buffer-substring, but those use ;; the current buffer by default (and in Emacs, they can't use others). ;; Also conditionalised use of region-exists-p. ;; --Magnus Henoch (require 'url) (defvar google-search-maxlen 50 "Maximum string length of search term. This prevents you from accidental= ly=20 sending a five megabyte query string to Netscape.") (defun google-it (search-string) "Search for SEARCH-STRING on google." (interactive "sSearch for: ") (browse-url (concat "http://www.google.com/search?client=3Dxemacs&q=3D" (url-hexify-string (encode-coding-string search-string 'utf-8))))) (defun google-search-selection () "Create a Google search URL and send it to your web browser." (interactive) (let (start end term url) (if (or (not (fboundp 'region-exists-p)) (region-exists-p)) (progn (setq start (region-beginning) end (region-end)) (if (> (- start end) google-search-maxlen) (setq term (buffer-substring start (+ start google-search-max= len))) (setq term (buffer-substring start end))) (google-it term)) (beep) (message "Region not active")))) (provide 'google-search) ;;; End of file. --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --=-=-=--