Initial Commit
[packages] / xemacs-packages / net-utils / webster-www.el
1 ;;; webster-www.el --- Look up a word in WWW Merriam-Webster dictionaries
2
3 ;; Copyright (c) 1997, 1998 Tomasz Cholewo <t.cholewo@ieee.org>
4
5 ;; Authors: Tomasz Cholewo <t.cholewo@ieee.org>
6 ;;          Soren Dayton <csdayton@cs.uchicago.edu>
7 ;; Modified: 1998/04/05
8 ;; Version: 1.2
9 ;; Keywords: comm, hypermedia
10
11 ;; This file is part of XEmacs.
12
13 ;; XEmacs is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; XEmacs is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 ;; 02111-1307, USA.
27
28 ;;; Synched up with: not in FSF.
29
30 ;;; Code:
31 (eval-when-compile
32   (autoload 'w3-form-encode-xwfu "w3-forms"))
33
34 (defcustom webster-www-url-format "http://www.m-w.com/cgi-bin/mweb?book=%s&va=%s"
35   "URL format to reference for Webster's dictionaries.
36 It is used in a call to `format' with a book name
37 (\"Dictionary\" or \"Thesaurus\") as its first argument
38 and a word to look up as its second argument."
39   :type 'string)
40
41 (defun webster-www-dictionary (arg)
42   "Look up a word in Webster Dictionary at http://www.m-w.com."
43   (interactive (list (webster-www-prompt "Dictionary")))
44   (webster-www-fetch "Dictionary" arg))
45
46 (fset 'webster-www (symbol-function 'webster-www-dictionary))
47
48 (defun webster-www-thesaurus (arg)
49   "Look up a word in Webster Thesaurus at http://www.m-w.com."
50   (interactive (list (webster-www-prompt "Thesaurus")))
51   (webster-www-fetch "Thesaurus" arg))
52
53 (defun webster-www-prompt (book)
54   (let* ((prompt (concat
55                   (concat "Look up word in Webster " book " (")
56                           (current-word) "): "))
57          (arg (read-string prompt)))
58     (if (equal "" arg) (current-word) arg)))
59
60 (defun webster-www-fetch (book word)
61   (require 'url)
62   (require 'w3-forms)
63   (require 'browse-url)
64   (browse-url
65    (format webster-www-url-format
66            book
67            (w3-form-encode-xwfu word))))
68
69 (provide 'webster-www)
70
71 ;;; webster-www.el ends here