;;; simple-web.el --- Simple Web functions ;; Author: Peter Breton ;; Created: Sat Nov 30 1996 ;; Version: $Id: simple-web.el,v 1.1 1996/12/01 13:36:23 peter Exp $ ;; Keywords: ;; Time-stamp: <96/12/01 08:36:08 peter> ;;; Commentary: ;; ;; This package defines a macro 'simple-web-define', which is ;; used to associate a URL with a function. It can be used to do ;; things like: ;; ;; * Click on a word in Emacs, launch a Web query to look up that ;; word in a dictionary ;; * Run search engine queries from emacs ;; ;; 'Simple-web' has some similarities with other efforts like 'altavista' ;; and 'webjump' by Neil W. Van Dyke . One difference is that ;; 'simple-web' only intends to create Lisp functions which are associated ;; with URLs, not provide a hotlist. You can also call the 'simple-web' ;; functions from Lisp programs, while 'webjump' is intended for interactive ;; use. ;; ;; Also, I find maintaining URLs in both a browser and Emacs tedious; ;; 'simple-web' is intended to only use the URLs I need, and to make ;; changing them as simple as possible. ;; ;; Defining new functions: ;; ;; Generally the way to do it is: ;; ;; 1) Find an interesting Web resource ;; 2) Make a query on it with a browser ;; 3) Cut and paste the URL that results from your query ;; 4) Substitute '%s' for your query ;; 5) Create a 'simple-web-define' macro using the result from 4) ;; ;;; Change log: ;; $Log: simple-web.el,v $ ;; Revision 1.1 1996/12/01 13:36:23 peter ;; Initial revision ;; ;;; Code: (require 'thingatpt) ;; Extend this to multiple arguments (defmacro simple-web-define (name prompt url &optional docstring) "Define a simple web function with NAME. This function uses PROMPT to obtain WORD, which is inserted into URL, using the 'format' function. If provided, DOCSTRING is used for the function's documentation" (let ((description (or docstring ""))) (` (defun (, name) (word) (, description) (interactive (list (read-string (, prompt) (or (word-at-point) "")))) (require 'browse-url) (let ((the-url (format (, url) word))) (funcall browse-url-browser-function the-url)))))) (simple-web-define web-search "Search for Word: " "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q=%s" "Search Alta Vista") (simple-web-define web-search-dictionary "Lookup word in dictionary: " "http://www.notredame.ac.jp/cgi-bin/wn.cgi?%s" "Look up word in dictionary") (simple-web-define web-search-thesaurus "Lookup word in thesaurus: " "http://humanities.uchicago.edu/cgi-bin/ROGET.sh?word=%s" "Look up word in thesaurus") (simple-web-define web-search-anagram "Anagrams for word: " "http://www.wordsmith.org/awad-cgibin/anagram?%s" "Look up word in anagram dictionary") (simple-web-define web-search-acronym "Lookup acronym: " "http://www.ucc.ie/cgi-bin/acronym?%s" "Look up word in acronym dictionary") (provide 'simple-web) ;;; simple-web.el ends